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 :(
{
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 :(