PDA

View Full Version : Linked combobox nad twice query in combobox



Forn
16 Apr 2012, 11:25 AM
Hello. I have the next code:



{
xtype: 'combobox',
cls: 'form-label',
id: 'cbRegion',
fieldLabel: 'Регион',
anchor: '100%',
displayField: 'name',
valueField: 'id',
store: 'Etersoft.Sales.Cabinet.store.DSRegion',
autoShow: false
},
{
xtype: 'combobox',
cls: 'form-label',
id: 'idCity',
displayField: 'name',
valueField: 'id',
store: 'Etersoft.Sales.Cabinet.store.DSCity',
fieldLabel: 'Город <span style=\'color: #FF0000\'>*</span>',
allowBlank: false,
anchor: '100%'
}


and next listener:


cbRegion_onSelect: function(combo, records, eOpts){
selectedRegionId = records[0].data.id;
var cbCity = Ext.getCmp('idCity');
cbCity.clearValue();

store = cbCity.store;

store.clearFilter();
store.filter('regionId', selectedRegionId);

cbCity.bindStore(store);

//cbCity.store.load(function(records, operation, success) {});
}


Store:


Ext.define('Etersoft.Sales.Cabinet.store.DSCity', {
extend: 'Ext.data.Store',
model: 'Etersoft.Sales.Cabinet.model.City',

remoteFilter: true,

proxy: {
type: 'ajax',
url: basePHPUrl+'?ds=cabinet_get_city_list',
reader: {
type: 'json'
},
}
});


For the first time all is good. But when i change second time the region combobox and the city load All City without filters. What I do wrong?

And one the last question: the data to the store is loaded with method:
Ext.getCmp('cbRegion').getStore().load
And all is good, except when i click to expand combobox is send one more request to the server and collapse the result, so i must expand it twice :(

jay@moduscreate.com
15 May 2012, 4:51 AM
What you could do is set the store's proxy's extraparams property. This will allow remote filtering to work.

vietits
15 May 2012, 5:41 AM
Try to fix your code as below:


cbRegion_onSelect: function(combo, records, eOpts){
selectedRegionId = records[0].data.id;
var cbCity = Ext.getCmp('idCity');
cbCity.clearValue();

store = cbCity.store;

store.clearFilter(true); // suppress firing event that cause loading request.
store.filter('regionId', selectedRegionId);

// cbCity.bindStore(store); // no need to bind to combobox again

//cbCity.store.load(function(records, operation, success) {});
}