Cascading ExtJs combobox

Cascading ExtJs combobox

Below is the way it works.

//function that gets city store
function getCityStore()
{
var store = new Ext.data.JsonStore({
url: ‘get-city-by-country-id’,
//baseParams: countryId:countryIdVar,
fields: [
{name:’cityId’, type:’int’},
‘cityName’
]
});
return store;
}

//than I have a countries combo
var countries = new Ext.form.ComboBox({
id:’country’,
store: getCountryStore(),
typeAhead: true,
triggerAction: ‘all’,
emptyText: ‘…’,
listeners: {
select: {
fn:function(combo, value) {
var modelDest = Ext.getCmp(‘city’);
//set and disable cities
modelDest.setDisabled(true);
modelDest.setValue(“);
modelDest.store.removeAll();
//reload region store and enable region
modelDest.store.reload({
params: { countryId: combo.getValue() }
});
modelReg.setDisabled(false);
}
}
}
})

Hope it will help someone … :)

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *

What is 6 + 4 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)