2015-05-20 36 views
2

我有一個網格,其中有一列組合框。我需要根據像下面的記錄過濾掉組合框的值:如何根據記錄的值在editorgrid的組合框中過濾商店?

id | name |  options 
====================================== 
1 | string | combobox(1,2,3) 
2 | string | combobox(1,2,3,4,5) 
3 | string | combobox(1,2,3) 
1 | string | combobox(1,2,3) 

所以,最後我要求的基礎上id列選項的值。以下是我的extjs網格列配置。

columns: [{ 
       header: 'id', 
       dataIndex: 'id', 
       id: 'id', 
       hidden: true 
      },{ 
       header: 'Name', 
       dataIndex: 'name', 
       id: 'name', 
       menuDisabled: true, 
       flex : 1 
      },{ 
       header: 'options', 
       dataIndex: 'options', 
       id: 'options', 
       menuDisabled: true, 
       flex : 1, 
       editor : { 
        xtype : 'combo', 
        store: optionStore, 
        valueField: 'id', 
        displayField: 'name', 
        triggerAction: 'all', 
        mode : 'local', 
        disabled: true, 
        listners: { 
         expand: this.filterFunc(this) 
        } 
       }, 
       renderer: this.columnRenderer 
      }] 

如何在ExtJS editorgrid中篩選存儲而不使用不同的行。

PS - 我使用ExtJS的3.4版本

回答

1

可以使用的渲染器,它應該是這樣的:

renderer: function(value, metaData, record, rowIndex, colIndex, store) { 
    value.store.filter([ 
     { 
      property: 'filteredProperty', 
      value: record.get('id') 
     } 
    ]); 
} 
+0

感謝它,但它不適合我,因爲我使用特殊的渲染器在下拉菜單中顯示值。 –

+0

該渲染器如何顯示?是否有可能使用該渲染器來過濾屬性? – MarthyM

+0

否@MarthyM,改變渲染器並不複雜。儘管你的解決方案完美運行,但我仍然在發佈解決問題的方法。 –

1

我用下面列的配置與聽衆expand其過濾器的商店,而擴大組合框列表。

{ 
    header: 'options', 
    dataIndex: 'options', 
    id: 'options', 
    menuDisabled: true, 
    flex : 1, 
    editor : { 
     xtype : 'combo', 
     store: optionStore, 
     valueField: 'id', 
     displayField: 'name', 
     triggerAction: 'all', 
     mode : 'local', 
     disabled: true, 
     listeners: { 
      expand : function(combo){ 
       var id = Ext.getCmp('grid').getSelectionModel().selection.record.data.id; 
       combo.store.filter('attributeId',attributeId); 
      } 
     } 
    }, 
    renderer: this.columnRenderer 
} 
+0

偉大的解決方案。不過,我個人會使用'afterrender'聽衆。如果使用'expand',則可以在展開之前顯示默認值,該值不在您的過濾列表中。 – MarthyM

+1

感謝您的關注,但沒有這樣的價值,因爲我已經在數據庫中添加了約束條件。 :) –

相關問題