问题描述
我有两个要求绑定EXT Js组合
I have two requirement to bind the EXT Js combo
- 组合中的第一个项目应该有固定的文本,如Unfilterd
-- The first Item in the combo should have the fixed text such as "Unfilterd"
- 之后,我需要将数据存储绑定到上述组合。数据存储区重新创建了columnA值,因此如何对数据存储区进行过滤,以使其在绑定组合之前在列A中具有不同的行。
-- 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.
注意:
我使用数据存储绑定网格panle,我不想创建另一个对数据库的调用。这就是为什么我寻找一个解决方案来过滤Ext Js数据存储的数据的原因。
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.
我的示例代码如下
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());
}}
}
});
推荐答案
您可能需要创建另一个存储对象内容您需要。但是没有必要从数据库中重新获取数据 - 您可以使用 extManager1.GetTemplateDetails
存储中的数据填充新存储。请查看 - 它可用于从现有商店获取不同的值。
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.
这篇关于Ext Js组合按不同项目过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!