ExtJS 组合框过滤器 [英] ExtJS combobox filter
问题描述
我有两个组合框.第一个用于选择地区,第二个用于选择省.应出现在省组合框中的值将基于在区域组合框中选择的值.
I have two comboboxes. The first one is for selecting a region, and the second one is for selecting a province. The values that should appear in the province combobox will be based on the value selected in the region combobox.
区域组合框代码:
xtype: 'combobox',
label: 'Region ID',
margin: '10 20',
flex: 1,
valueField: 'regionid',
displayField: 'regionname',
store: 'RegionStore',
minLength: 1,
id: 'region_id',
reference: 'region_id',
name: 'region_id',
listeners: {
select: function(combo, value) {
var id = Ext.getCmp('province'),
store = id.getStore();
if (!value) {
store.getFilters().removeAll();
}
else {
store.filter('regionid', val)
}
}
}
省组合框代码:
label: 'Province',
margin: '10 20',
flex: 1,
queryMode: 'remote',
store: 'ProvinceStore',
valueField: 'provinceid',
displayField: 'provincename',
minLength: 1,
id: 'province',
name: 'province',
reference: 'province'
我没有收到任何错误,但是当我单击省组合框时(假设我已经为区域组合框选择了一个值),省组合框中显示的值没有被过滤,而是所有结果都是显示.我一直在这几天.有人可以帮忙吗?
I'm not getting any errors but when I click the province combobox(assuming that I have already selected a value for the region combobox), the values displayed in the province combobox are not filtered, instead, all of the results are displayed. I have been on this for days. Is there someone who can help?
推荐答案
您正在使用 queryMode: 'remote'
,以便您的服务器返回数据.前端无法控制,返回什么.
You are using queryMode: 'remote'
, so that your server returns the data.
The frontend has no control, what is returned.
在你的例子中,val
应该是 value
.
Plus in your example val
should be value
.
我会选择连锁店,它有一个基于选择的过滤器.
I would go with a chained store, that has a filter based on the selection.
这是一个小提琴来展示这一点:小提琴
Here is a fiddle to show this: Fiddle
这与您的其他问题
这篇关于ExtJS 组合框过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!