Extjs 如何找到包含具有特定值的组合框的容器
请参阅ff: 主容器:Extjs 如何找到包含具有特定值的组合框的容器,extjs,Extjs,请参阅ff: 主容器: xtype: 'container', name: 'mainContainer', items: [ { xtype: 'myXtype', name: 'some1' }, { xtype: 'myXtype', name: 'some2' }, { xtype: 'myXtype', name: 'some3' } ] m
xtype: 'container',
name: 'mainContainer',
items: [
{
xtype: 'myXtype',
name: 'some1'
},
{
xtype: 'myXtype',
name: 'some2'
},
{
xtype: 'myXtype',
name: 'some3'
}
]
myXtype:
Ext.define('blabla.MyXtype', function() {
....
alias: 'widget.myXtype',
items: [
{
xtype: 'combo',
name: 'combo1'
},
{
xtype: 'combo',
name: 'combo2'
},
{
xtype: 'combo',
name: 'combo3'
}
....
});
现在,我想找到包含具有特定值的确切组合的myXtype
容器。比如说,我有值(test1、test2、test3)
和ffmyXtype
及其值:
some1: { //not this, combo values not matching my values
combo1: 'not this1'
combo2: 'not this2'
combo3: 'not this3'
},
some2: { //not this also, combo3 is null
combo1: 'test1',
combo2: 'test2',
combo3: null
},
some3: { //should be this 1
combo1: 'test1',
combo2: 'test2'
combo3: 'test3'
}
我已尝试过此选项,但这会引发无效的组件查询选择器错误:
var found = mainContainer.down('![xtype=myXtype] combo[value=test1] combo[value=test2] combo[value=test3]');
我知道Extjsdown()
函数可以将CSS选择器作为参数,但不幸的是,CSS中没有父选择器,对吗
我还尝试了jQuery的:has()
选择器,但运气不好:
var found = mainContainer.down('[xtype=myXtype]:has(combo[value=test1], combo[value=test2], combo[value=test3])')
任何帮助都将不胜感激
注意:有这样一个想法:循环foreachmyXtype
,然后再次循环它的combo
子项,检查它们的值,但我认为这不是很理想。另外,我想要一个ExtJS
答案
编辑:我选择了做一个循环,但我将把这个问题留在这里供将来参考
干杯
你可以使用ID`,也可以使用特定的组合,在这种情况下让一些商店进入商店不,我不能使用ID,因为myXtype
是动态添加到fly上的maincainer
中添加一个getValue
方法到myXtype
。然后,只需执行一个查询来获取xtypes并比较循环中的值。循环的效率不会低于查询,因为查询所做的工作大致相同(如果不是更多的话)。您可以使用ID`,也可以使用特定的组合,在这种情况下让某个存储命中存储否,我无法使用ID,因为myXtype
被动态添加到fly上的maincainer
中添加getValue
方法到myXtype
。然后,只需执行一个查询来获取xtypes并比较循环中的值。循环的效率不会低于查询,因为查询所做的工作大致相同(如果不是更多的话)。