PDA

View Full Version : Combobox not updating after store.load()



jeloff
17 Jul 2014, 12:45 AM
Hi all,

My Combobox isn't reflecting the change when I load the store. It just stays empty.

I have the following Combos:


{
xtype: 'combobox',
anchor: '100%',
itemId: 'giftCrudCategory',
maxWidth: 300,
fieldLabel: 'Category',
name: 'category',
allowBlank: false,
allowOnlyWhitespace: false,
displayField: 'name',
queryMode: 'local',
queryParam: 'filter',
store: 'categoryAjaxStore',
valueField: 'name'
},
{
xtype: 'combobox',
anchor: '100%',
itemId: 'giftCrudType',
maxWidth: 300,
fieldLabel: 'Type',
name: 'mainType',
allowBlank: false,
allowOnlyWhitespace: false,
displayField: 'name',
queryMode: 'local',
queryParam: 'filter',
store: 'maintypeAjaxStore',
valueField: 'name'
},

The "giftCrudCategory" combo has the following function in it's onSelect event (this is in a controller).


onGiftCrudCategorySelect: function(combo, records, eOpts){
store = Ext.getStore('maintypeAjaxStore');
store.filter('category', combo.getValue());
store.load();
}

This fires correctly. The ajax call gets made and the correct data gets passed back. I've logged the store data and the store has the correct data as well. I've even gotten the store from the combobox, ie (combo.getStore().data) and that also has the data. Yet when I click to select a value there is nothing, it doesn't even open.

It is defined exactly like the Category combo and the Category combo does work. I'm not sure what I'm doing wrong here.

jeloff
17 Jul 2014, 4:42 AM
It seems I was mistaken, the store has no values in after the load call. However the response from the server is correct. It seems to only fail after I apply a filter to the store. If I load the store without filters it works.

So if I do:


onGiftCrudCategorySelect: function(combo, records, eOpts){
store = Ext.getStore('maintypeAjaxStore');
store.load();
}

Instead of:

onGiftCrudCategorySelect: function(combo, records, eOpts){
store = Ext.getStore('maintypeAjaxStore');
store.filter('category', combo.getValue());
store.load();
}

It works and the combobox gets updated, but this is ofcourse a problem, as I'd like it to display only the items for the chosen category and not all of them. Is there a rule concerning Combos and Store filtering that I missed? Can this not be done? This exact method works with my grids so why is the combo different?

*Edit: I have also tried the filter() without the load() function afterwards, it still does the call and gets the wanted data, but the store/combo is still empty.

jeloff
17 Jul 2014, 5:18 AM
I solved the problem. I forgot to set "remoteFilter: true" on the store.

It seems odd to me that it still queried the server even though it was set to false, but it's working now so I'm happy.