PDA

View Full Version : Combobox and store problem



Szandra
9 Oct 2013, 12:38 AM
Hi!
I'm having problems with a combobox and its store.
I have two comboboxes and after changing the first, I need to filter the second's store and set its value to the filtered store first value. The problem is that it sets the original store first value.
When I console.log the combobox's store it shows the filtered values, but when I'm logging it's first value it shows the original store's first value.
I tried bindStore() because I read it works for some people, but in my case it doesn't.


listeners: {
change: function(){
modules_name_store.filter([{property: 'filter', value:group_id}]);

console.log(modules_name_store);
// It shows the FILTERED store's value
console.log(modules_name_store.first());
// It shows the ORIGINAL store's first value

Ext.getCmp('modul_choose_tab4').bindStore(modules_name_store);
console.log(Ext.getCmp('modul_choose_tab4').store);
// It shows the FILTERED store's value
console.log(Ext.getCmp('modul_choose_tab4').store.first());
// It shows the ORIGINAL store's first value



Ext.getCmp('modul_choose_tab4').setValue(modules_name_store.first());
}
}

ettavolt
10 Oct 2013, 1:20 AM
Can you please show modules_name_store definition?

Szandra
10 Oct 2013, 1:29 AM
Yes, this is the store:



var modules_name_store = Ext.create('Ext.data.JsonStore', {
fields: [
{name: 'module_id', type: 'int'},
{name: 'shortname', type: 'string'}
],
remoteSort: true,
remoteFilter: true,
proxy: {
type: 'ajax',
url: BASE_URL + "index.php/admin/getModulesName",
actionMethods: {
create : 'POST',
read : 'POST',
update : 'POST',
destroy: 'POST'
},
writer: {
type: 'json',
root: 'update',
writeAllFields: true,
allowSingle: false,
encode: true
},
reader: { root:'modulesname', totalProperty:'modulesname_count' }
},
autoLoad: false
});

ettavolt
10 Oct 2013, 1:55 AM
remoteFilter: true config makes store to request data from server.
Certainly, the request is asynchronous, that's why you got record from not-filtered set.
You may try to remove this config (by default it is false) or set combo's value in 'load' event listener.