ExtJS链式存储过滤器未过滤 [英] ExtJS chained store filter not filtering

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

问题描述

组合框过滤器不起作用,我不确定为什么。我有两个组合框,一个是,另一个是城市。当我选择一个省时,将使用province_id根据所选省过滤城市组合框。

Filter for combobox is not working and I am not sure why. I have two comboboxes, one is province and other is city. When I select a province, the city combobox will be filtered according to the selected province using the province_id.

查看模型代码:

data: {
selectedProvince: null
},

stores: {
  province: {
    fields: [ 'province_id', 'province_name' ],
    proxy: {
      type: 'ajax',
      url: '*some url to province*',
      reader: {
        type: 'json',
        rootProperty: 'data'
      }
    }
  },

  city: {
    fields: [ 'city_id', 'city_name', 'province_id' ],
        proxy: {
      type: 'ajax',
      url: '*some url to city*',
      reader: {
        type: 'json',
        rootProperty: 'data',
      }
    },

  },

  filteredStore: {
    type: 'chained',
    source: '{city}',
    remoteFilter: false,
    filters: [{
      property: 'province_id',
      value: '{selectedProvince}'
    }],

  }
}

省组合框代码:

xtype: 'combobox',
label: 'Province',
valueField: 'province_id',
displayField: 'province_name',
bind: {
  store: '{province}',
  value: '{selectedProvince}'
}

城市组合框代码:

xtype: 'combobox',
label: 'City',
valueField: 'city_id',
displayField: 'city_name',
bind: {
  store: '{filteredStore}'
}

我尝试过这些:

https: //fiddle.sencha.com/#fiddle/983&view/editor

https://fiddle.sencha.com/#view/editor&fiddle/2dt0

我也尝试过放置组合框内的过滤器是这样的:

And I have also tried placing the filter inside the combobox like this:

xtype: 'combobox',
label: 'City',
valueField: 'city_id',
displayField: 'city_name',
bind: {
   store: '{filteredStore}',
   filters: {
      property: 'province_id',
      value: '{selectedProvince}'
    }
 }

而且,结果仍未过滤。我正在使用extjs 7,如果有帮助的话。谢谢

And still, the results are still not filtered. I'm using extjs 7, if that helps. Thanks

推荐答案

这是您的其他问题

答案仍然在此小提琴

我已对其进行更新以匹配您在该线程中的问题。

I updated it to match your question in this thread.

您必须将两个商店都设置为 autoLoad:true ,将组合框设置为 queryMode:'local '

You have to set both stores to autoLoad: true and the combobox to queryMode: 'local'.

这篇关于ExtJS链式存储过滤器未过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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