I am trying to set up a combo box that is dependent on an other combo box. My script is working fine for the first value in my first combo box and it displays the correct dependent values in the second combo box. However it stops working when I try changing the value in my first combo box.
init : 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);
},
});
I don't know what is the issue. Can someone please suggest a fix to my code?