Ext Js Combo Filter by distinct items
I have two requirement to bind the EXT Js combo
-- The first Item in the combo should have the fixed text such as "Unfilterd"
-- After that I need to bind the data store to the above combo. The datastore has repated columnA values, so how can filter the datastore so that it has distinct rows in 开发者_运维技巧a columnA before binding the combo.
Note:
I am using the data store to bind the grid panle aswell, I do not want to create another call to database. That's the reason why I am looking for a solution to filter the data by Ext Js datastore.
My sample code is as below
extManager1.comboFilter = new Ext.form.ComboBox({
editable: false
, id: 'BaseTemplate'
, fieldLabel: 'Base Templates'
, name: 'BaseTemplate'
, editable: false
, store: extManager1.GetTemplateDetails
, displayField:'FilterBy'
, valueField: 'value'
, mode: 'local'
, boxLabel: 'BaseTemplate'
, typeAhead: true
, triggerAction: 'all'
, forceSelection: true
, selectOnFocus: true
, emptyText:'Unfilterd'
,listeners:{select:{fn:function(combo, value) {
//This code filters the grid panel data by selected combo value
Ext.getCmp('TemplateGridPanel').store.filter('productdisplayheading', combo.getValue());
}}
}
});
You will probably need to create another store object with the contents you need. But there's no need to fetch the data again from the database - you can populate the new store with the data in your extManager1.GetTemplateDetails
store. Take a look at the collect method of ExtJS Store - it can be used to fetch distinct values from an existing store.
精彩评论