PDA

View Full Version : linked combo box error



venkatadineshp
25 Jul 2011, 6:03 AM
Hi,

I am having issues when I try to try to populate data of second combobox from first one. I have a change listener for first combo box. I have a global variable cityOfState in which I have the list for second combo box. But it does not work. Can any one please help me



Ext.regModel('City', {
fields : [ {
name : 'name',
type : 'string'
}, {
name : 'id',
type : 'int'
} ]
});

Ext.regModel('State', {
fields : [ {
name : 'name',
type : 'string'
}, {
name : 'sid',
type : 'int'
} ]
});
var cityOfState;
var stateStore = new Ext.data.Store({

model : 'State',
sorters : [ {
property : 'name',
direction : 'DESC'
} ],

data : [ {
sid : 1,
name : 'Ohio'
}, {
sid : 2,
name : 'Indiana'
}
]
});
var cityStore = new Ext.data.Store({
model : 'City',

data : [ {
id : 1,
name : 'Cincinnati'
}, {
id : 1,
name : 'Columbus'
}, {
id : 1,
name : 'Hamilton'
}, {
id : 2,
name : 'Muncie'
}, {
id : 2,
name : 'Anderson'
}, {
id : 2,
name : 'Indianapolis'
} ]
});

Trail.views.OriginForm = new Ext.extend(Ext.form.FormPanel, {
items : [ {
xtype : 'fieldset',
title : 'Origin',
name: 'origin',
instructions : 'Please pick the state',
items : [ {
xtype : 'selectfield',
name: 'StatePicker',
label : 'State',
store : stateStore,
displayField : 'name',
valueField : 'sid',
listeners : {
'change' : function(thisComponent) {
//thisComponent.getStore().load();
cityOfState = new Ext.data.Store({
model:'City',
data:cityStore.filter('id',thisComponent.getValue())
});
Ext.Msg.alert('State value changed', thisComponent.getValue(),Ext.emplyFn);

}
}

}, {
xtype : 'selectfield',
label : 'City',
name: 'CityPicker',
store :cityOfState
displayField : 'name',
valueField : 'id'
} ]
} ]
});



Thanks