Ext Js Combo 按不同项目过滤
我有两个要求来绑定 EXT Js 组合
- 组合中的第一个项目应该具有固定文本,例如“Unfilterd”
- 之后我需要将数据存储绑定到上面的组合。数据存储已重复列 A 值,因此如何过滤数据存储,使其在绑定组合之前在列 A 中具有不同的行。
注意:
我也使用数据存储来绑定网格面板,我不想创建另一个对数据库的调用。这就是我寻找通过 Ext Js 数据存储区过滤数据的解决方案的原因。
我的示例代码如下
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());
}}
}
});
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());
}}
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要使用您需要的内容创建另一个商店对象。但无需再次从数据库中获取数据 - 您可以使用
extManager1.GetTemplateDetails
存储中的数据填充新存储。看一下ExtJS Store的collect方法 - 它可用于从现有存储中获取不同的值。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.