PDA

View Full Version : How to pass parameter onchange event of a extjs combo



ahsan
26 Feb 2010, 7:26 AM
I try to develop a linked combobox in extjs(3.1.1) in asp.net(fram work3.5).
I try to fill up the one combobox onchange event of another combobox,like when select a country from a combobox then fill up the state of the combobox.

For stateCombobox:


var ComboDistrict = new Ext.form.ComboBox({
store: new Ext.data.ArrayStore({
fields: ['Id','cid','name'],
data: districtArray
}), //direct array data
disabled: true,
id: 'cmbDistrict',
name: 'cmbDistrict',
transform: 'cmbDistrict',
valueField: 'Id',
displayField: 'name',
mode: 'local',
typeAhead: false,
editable: false,
triggerAction: 'all',
emptyText: 'Select a district...',
selectOnFocus: true
});


For Country combobox:


var ComboCountry = new Ext.form.ComboBox({
store: new Ext.data.ArrayStore({
fields: ['Id', 'name'],
data: CountryArray
}), //direct array data
transform: 'cmbCountry',
valueField: 'Id',
displayField: 'name',
mode: 'local', //it means data get from this page
typeAhead: true,
triggerAction: 'all',
emptyText: 'Select a Country...',
selectOnFocus: true,
listeners: //for call the event of the control
{
select: //here call the select event of combo
{
fn: function(combo, value)//here combo means cmbCountry
{
var comboDistrict = Ext.getCmp('cmbDistrict');
comboDistrict.clearValue(); //clear the previous value
//comboDistrict.store.filter('cid', combo.getValue());//get the country id in cid parameter for filter
comboDistrict.store.load({
params:
{
id: combo.getValue()
}
});
}
}
}
});