我正在尝试设置一个依赖于其他组合框的组合框。我的脚本对于我的第一个组合框中的第一个值工作正常,它在第二个组合框中显示正确的依赖值。但是,当我尝试更改第一个组合框中的值时,它会停止工作。
初始化 : function(){ var me = this;
var roles=[
['Gen', 'General'],
['Neuro', 'Neurotoxin User'],
['Admin', 'Administrator (System Administrator Only)']
];
Ext.define('Testfile.model.Role', {
extend: 'Ext.data.Model',
fields: ['abbr', 'role']
});
var rolesStore = new Ext.data.Store({
model: 'Testfile.model.Role',
proxy: {
type: 'memory',
reader: {
type: 'array'
}
},
data: roles
});
var tests=[
[1, 'Gen', 'Test1'],
[2, 'Gen', 'Test3'],
[3, 'Neuro', 'Test2']
];
Ext.define('Testfile.model.Test', {
extend: 'Ext.data.Model',
fields: ['id', 'abbr', 'test']
});
var testsStore = new Ext.data.Store({
model: 'Testfile.model.Test',
proxy: {
type: 'memory',
reader: {
type: 'array'
}
},
data: tests
});
me.form=Ext.create('Ext.form.Panel',{
renderTo:document.body,
bodyPadding: 10,
width: 550,
style:'margin:16px',
height: 300,
title:'Linked Combos',
defaults: {xtype:'combo'},
items: [{
fieldLabel: 'Application Role',
id:'firstComboID',
store:rolesStore,
valueField: 'abbr',
displayField: 'role',
typeAhead: true,
forceSelection: true,
allowBlank: false,
editable: true,
triggerAction: 'all',
listeners: {
select:{fn:function(combo, value) {
var sample = Ext.getCmp('secondComboID');
sample.store.filter('abbr', combo.getValue());
sample.clearValue();
}}
}
},{
fieldLabel: 'Select Test',
id:'secondComboID',
store:testsStore,
valueField: 'id',
displayField: 'test',
typeAhead: true,
forceSelection: true,
allowBlank: false,
editable: true,
triggerAction:'all',
lastQuery:''
}
]
});
me.container.add(me.form);
},
});
我不知道是什么问题。有人可以建议我的代码修复吗?