Ext Js Combo Filter by distinct items

心已入冬 提交于 2019-12-12 15:21:56

问题


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());               

                }}

                }

    });

回答1:


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.



来源:https://stackoverflow.com/questions/5614771/ext-js-combo-filter-by-distinct-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!