Extjs链接组合-让父值具有相同的子值
如果父值具有唯一标识符,则可以使用链接组合。 但是,我在父组合中有4个选项,它们应该与子组合具有相同的值。我在存储中给了它们相同的标识符,但是当我选择它们中的任何一个时,组合中的值都不会改变 是否可以在不复制所有值的情况下执行此操作 商店 组合Extjs链接组合-让父值具有相同的子值,extjs,combobox,Extjs,Combobox,如果父值具有唯一标识符,则可以使用链接组合。 但是,我在父组合中有4个选项,它们应该与子组合具有相同的值。我在存储中给了它们相同的标识符,但是当我选择它们中的任何一个时,组合中的值都不会改变 是否可以在不复制所有值的情况下执行此操作 商店 组合 您可以改用filterBy函数。以下是方法: opCombo.store.filterBy( function(record, id) { if((record.data.id == 1 || record.data.id == 2)
您可以改用filterBy函数。以下是方法:
opCombo.store.filterBy( function(record, id) {
if((record.data.id == 1 || record.data.id == 2) && (this.id == 1 || this.id == 2)) {
// specify index that you want to exclude when getting say parent combo value 1 or 2
return false; // excludes the record in the store
} else {
return true; // includes the record in the store.
}
} , combo );
所做的只是在子组合中显示每个值,而不是选择一个值。我遇到的问题是,几个父选项具有相同的子选项,但父选项显示这3个选项中的第一个(名称),无论选择了哪一个
xtype:'combo',
id: 'fieldSelecCmb1',
width: 125,
displayField: 'field',
valueField: 'fid',
hideLabel: true,
store: storeField ,
triggerAction: 'all',
mode: 'local',
value: "Choose a field",
listeners:{
select: {
fn:function(combo, value){
var id = combo.id;
var rowNo = id.charAt(id.length-1);
var opCombo = Ext.getCmp("optionSelectCmb"+rowNo);
opCombo.clearValue();
opCombo.store.filter("fid", combo.getValue());
}
}
opCombo.store.filterBy( function(record, id) {
if((record.data.id == 1 || record.data.id == 2) && (this.id == 1 || this.id == 2)) {
// specify index that you want to exclude when getting say parent combo value 1 or 2
return false; // excludes the record in the store
} else {
return true; // includes the record in the store.
}
} , combo );