PDA

View Full Version : remote filtering of my store will call the store twice



dobberph
28 Jun 2013, 5:26 AM
Hi guys,

my problem is, that I filter the store at one position in my code. This is no problem and it works, but the script calls the backend php-file twice. The first time with the filter, the second time without the filter. This would cause no trouble, if the call without the filter would everytime be called first, but sometimesit is called as the second an d then the filtering seems not to work.

I already tried something according to configuration of the store and reader but with no success.

Here are some I think interesting parts of my scripts:

Store:


Ext.define('Newsflash.store.NewsStore', {
extend: 'Ext.data.Store',
alias: 'store.newsstore',


requires: [
'Newsflash.model.NewsModel'
],


constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
autoSync: true,
model: 'Newsflash.model.NewsModel',
remoteFilter: true,
remoteSort: true,
storeId: 'newsflashStore',
pageSize: 15,
proxy: {
type: 'ajax',
api: {
create: 'pages/newsflash/backend/NewsflashBackend.php?action=insert',
read: 'pages/newsflash/backend/NewsflashBackend.php?action=list',
update: 'pages/newsflash/backend/NewsflashBackend.php?action=update',
destroy: 'pages/newsflash/backend/NewsflashBackend.php?action=delete'
},
reader: {
type: 'json',
idProperty: 'id',
root: 'rows',
useSimpleAccessors: true
},
writer: {
type: 'json',
root: 'rows'
}
}
}, cfg)]);
}
});


filter-function in the controller:


onFilterKeypressed: function(field, newValue, oldValue, eOpts) {
this.getNewsflashGridview().getStore().clearFilter();
this.getNewsflashGridview().getStore().filter('title', field.getValue());
}


Perhaps someone had the same problem and knows from where it may come.

Thansk a lot,
Tobias

P.S.: Here are the networks-calls in firefox.

dobberph
28 Jun 2013, 5:48 AM
And the answer is:

filter-function in the controller:


onFilterKeypressed: function(field, newValue, oldValue, eOpts) {
this.getNewsflashGridview().getStore().clearFilter(true);
this.getNewsflashGridview().getStore().filter('title', field.getValue());
}

Add a true to the clearFilter() - call. It says that the script should not reload the store after clearing the filters.

Best regards,
Tobias