2017-02-02 217 views
2

我有一個標籤面板只有幾個選項卡。其中一個包含網格,網格包含3個文件: 1個編輯器類型爲「textfield」的項目,以及2個編輯器類型爲「combobox」的項目。ExtJS Combobox錯誤:無法讀取未定義的屬性「商店」

問題:我想根據以前的組合框過濾組合框。但由於某種原因,它只能在第一次使用。之後,商店返回未定義。

這裏是我的代碼:

items:[{ 
    xtype: 'grid', 
    id:'schema', 
    border: false,  
    data:[], 
    columns: 
    [{ 
     text  : 'Size', 
     dataIndex: 'size', 
     id: "SizeDropdown", 
     width : 200, 
     sortable : true, 
     editor : { 
      xtype: 'combobox', 
      id:'SelectSize', 
      editable:true, 

      valueField: 'typeValue', 
      displayField: 'typeValue', 
      mode:'local', 
      lastQuery: '', 
      listeners:{ 
      }, 
      store: new Ext.data.SimpleStore({ 
       fields: ['size', 'typeValue'], 
       data: [ 
         ['char', '12'], 
         ['char', '30'], 
         ['char', '31'], 
         ['int', '250'], 
         ['int', '500'], 
         ['int', '1000'], 
        ] 
      }), 
      allowBlank: false, 
      validator: function(input){         
       return true; 
      } 
     } 
    }], 
    listeners: { 
     beforeitemclick: function (eventThis, record, rowIndex, e) { 

      var SizeStore = Ext.getCmp('SizeDropdown').editor.store 

      SizeStore.clearFilter(); 
      SizeStore.filter('size', record.data.type); 
     } 
    } 

'record.data.type'回報 '字符' 或 'INT',根據前組合框和過濾工作好。但只是第一次。之後,它打破了這裏:

var SizeStore = Ext.getCmp('SizeDropdown').editor.store 

,並返回:

Cannot read property 'store' of undefined 

我使用ExtJS的 「4.0.7」

+2

您可以移動商店類之外。通常定義它。我認爲在編輯器中定義商店並不是個好主意。你也可以在fiddle.sencha.com上用這種幫助重新創建你的問題會容易得多。 – pagep

+0

@pagep謝謝,我在課堂外宣佈了這家店,它工作。 :)如果您願意,請將其寫爲答案,我會接受它。 – Nyagolova

回答

0

聲明店外的標籤類做的工作。

這裏是我做過什麼:

 var sizeDropdownStore = new Ext.data.SimpleStore({ 
      fields: ['size', 'typeValue'], 
      data: [ 
        ['char', '12'], 
        ['char', '30'], 
        ['char', '31'], 
        ['int', '250'], 
        ['int', '500'], 
        ['int', '1000'], 
      ] 
     }); 


     ...{ 
      xtype: 'combobox', 
      id:'SelectSize', 
      editable:true, 
      valueField: 'typeValue', 
      displayField: 'typeValue', 
      mode:'local', 
      listeners:{ 
      }, 
      store: sizeDropdownStore, 
      allowBlank: false 
     }... 
相關問題