ExtJS组合框过滤器 [英] ExtJS combobox filter

查看:69
本文介绍了ExtJS组合框过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个组合框。第一个用于选择区域,第二个用于选择。在省组合框中应显示的值将基于在区域组合框中选择的值。

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 应该为

我会去一个连锁商店,该商店具有基于选择的过滤器。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆