extjs - ExtJS 绑定过滤器并在子组合框上选择默认值
问题描述
我正在尝试创建两个组合框。第一个显示国家名称,第二个显示省/州。这个想法是根据第一个组合的选择过滤第二个组合,并将“VisitingCountryProvince”的值作为默认选择。下面代码的问题是,它没有根据第一个组合框选择默认值。如果我删除绑定过滤器,第二个组合框会显示“VisitingCountryProvince”的正确值。
任何想法?
{
xtype: 'fieldset',
title: 'Visiting Country',
layout: 'anchor',
anchor: '-10',
collapsible: false,
defaults: {
xtype: 'combo',
labelStyle: 'font-weight: bold;',
flex: 1,
anchor: '0',
editable: false,
forceSelection: true,
allowBlank: false,
emptyText: 'Select...',
queryMode: 'local',
},
items: [{
name: 'VisitingCountry',
fieldLabel: 'Main',
reference: 'visitingCountryFieldRef',
publishes: 'value',
store: {
type: 'arraydropdownstore'
},
valueField: 'value',
displayField: 'value'
}, {
name: 'VisitingCountryProvince',
fieldLabel: 'Sub',
store: {
type: 'array',
fields: ['value', 'countryName']
},
bind: {
filters: {
property: 'countryName',
value: '{visitingCountryFieldRef.value}'
}
},
valueField: 'value',
displayField: 'value'
}]
},
我能找到的最接近问题的答案在这里,如何使用组合“发布”值和绑定来过滤另一个组合上的存储
我刚刚发现,我可以进行过滤或选择默认值,而不是两者兼而有之。如何从过滤列表中过滤和绑定默认值?
解决方案
您需要在第一个组合框的“选择”事件处理程序中编写过滤第二个组合存储值的逻辑。
{
name: 'VisitingCountry',
fieldLabel: 'Main',
reference: 'visitingCountryFieldRef',
publishes: 'value',
store: {
type: 'arraydropdownstore'
},
valueField: 'value',
displayField: 'value',
listeners:{
select:function(){
//Access the second[bound to second combobox]store and apply the
//filter, Also there are arguments for select event handler, for this
//Please refer docs.sencha.com for extjs version you are using.
}
}
}
推荐阅读
- c++ - 带有 std::vector 的 std::min_element
- node.js - 缺少对斜杠命令的访问
- python - 定义函数时,非默认参数遵循默认参数
- c# - 使用 c# 进行文件搜索
- polymorphism - 如何在jq中复制列表N次?
- python - 如何阻止交互式窗口将我的输出溢出到列中?
- google-sheets - 如何制作谷歌表格(或 Excel)甘特图,其中某些工作日(不一定在周末)不是完整的工作日?
- compilation - binutils-gdb 编译找不到 ncurses
- c++ - 在 C++ 中构建字节消息
- hugo - imageConfig (HUGO) 在构建站点时在哪里查找图像?