PDA

View Full Version : How to dynamically change the lists of a combo box when I trigger another combo box?



cc.lee
25 Mar 2011, 2:53 AM
I have developed a editorgrid and there are two columns

and these two columns are combo boxes.

I have create two datastores (A & B which stores the data of two combo boxes (1 and 2) respectively. The codes of these teo datastores are like this:

DataStore A



var AFormat = Ext.data.Record.create([
{name: 'id'}, {name: 'displayText'}
]);
var AStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: '../json/Data.aspx?table=A&condition=null'}),
reader: new Ext.data.JsonReader({
root: 'records', id: 'id', totalProperty:'totalCount'
},AFormat),
remoteSort : true
});


DataStore B


var BFormat = Ext.data.Record.create([
{name: 'id'}, {name: 'displayText'}
]);
var BStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: '../json/Data.aspx?table=A&condition=' + Parameter}),
reader: new Ext.data.JsonReader({
root: 'records', id: 'id', totalProperty:'totalCount'
},BFormat),
remoteSort : true
});



There is a value called Parameter which is used for generating dynamic datastore.
I would like to do something like this...

If combo box 1 changes, the value Parameter will be changed and I would also like to change the lists of values of combo box 2 by reloading the datastore B with changed Parameter. Is it possible to do so??

Thank you very much!

mcadirci
25 Mar 2011, 3:12 AM
comboBox1.on('select', handleCB1Select);

...
function handleCB1Select(){
combobox2.store.loadData([[1,'aa'][2,'bb']]);
}smt like this should work.