PDA

View Full Version : [SOLVED] dynamic combo listener problem



evang
30 Apr 2010, 4:19 PM
please help. thx. I try to search any post about combo in forum but still can't find solution. I have two combos. when select combo 1, can't activate combo 2. the code like below.



,
initComponent: function () {
//combo country
this.comboCountry = new Ext.form.ComboBox({
fieldLabel: 'Country',
anchor: '95%',
xtype: 'combo',
id: 'comboCountry',
valueField: 'country_id',
hiddenName: 'country_id',
displayField: 'country_name',
typeAhead: true,
triggerAction: 'all',
forceSelection: true,
editable: false,
emptyText: 'Choose...',
selectOnFocus: true,
allowBlank: false,
mode: 'remote',
store: new Ext.data.JsonStore({
url: 'Ajax/CountryAjax.php',
baseParams: {
action: 'listCountry'
},
fields: [{
name: 'country_id',
type: 'int'
},
{
name: 'country_name',
type: 'string'
}]
}),
listeners: {
select: function () {
var country = Ext.getCmp('comboCountry').getValue();
var city = Ext.getCmp('comboCitry');
//set and disable managers
city.setDisabled(true);
city.setValue('');
city.store.removeAll();
//reload city store
city.store.reload({
params: {
country_id: country
}
});
}
}
})
//combo city
this.comboCity = new Ext.form.ComboBox({
fieldLabel: 'City',
anchor: '95%',
xtype: 'combo',
id: 'comboCity',
valueField: 'city_id',
hiddenName: 'city_id',
displayField: 'city_name',
typeAhead: true,
triggerAction: 'all',
forceSelection: true,
editable: false,
emptyText: '--',
selectOnFocus: true,
allowBlank: true,
mode: 'local',
store: new Ext.data.JsonStore({
url: 'Ajax/CityAjax.php',
baseParams: {
action: 'listCity'
},
fields: [{
name: 'city_id',
type: 'int'
},
{
name: 'city_name',
type: 'string'
}]
})
})


also additional listener



/*
* Listener shot to load the form
*/
,
_onFormLoad: function (form, request) {
var data = request.result.data;
if (data.country_id)
{
var novoRegistro = new this.comboCountry.store.recordType({
country_id: data.country_id,
country_name: data.countriescountry_id
});
if (this.comboCountry.store.getCount() == 0) {
this.comboCountry.store.insert(0, novoRegistro);
}
this.comboCountry.setValue(data.country_id);
}
//shot a mask
this.el.unmask();
}

evang
1 May 2010, 7:33 AM
problem solved. thx ;)