PDA

View Full Version : pagingmemory + store Filters - Only searchs in the current page.



grpbhb
13 Mar 2013, 6:07 AM
Hi, I'm currently using FilterBar feature in my grid.
The store has a 'pagingmemory' proxy, and is buffered.
When I write some text in a column, this text is searched in the current page of the grid.
But, I need that the search take place in all the pages i have in memory.

Thank you!

Throstur
13 Mar 2013, 6:55 AM
Just posted this a few moments ago, probably the same case.
http://www.sencha.com/forum/showthread.php?258479-Column-filter-doesn%C2%B4t-filter-beyond-pagesize.

grpbhb
13 Mar 2013, 7:37 AM
I found the fix. The bug is in the method filter of the Store.
My solution in green.



filter: function(filters, value) {
if (Ext.isString(filters)) {
filters = {
property: filters,
value: value
};
}


var me = this,
decoded = me.decodeFilters(filters),
i = 0,
doLocalSort = me.sorters.length && me.sortOnFilter && !me.remoteSort,
length = decoded.length;


for (; i < length; i++) {
me.filters.replace(decoded[i]);
}


if (me.remoteFilter) {

delete me.totalCount;




if (me.buffered) {
me.pageMap.clear();
me.loadPage(1);
} else {

me.currentPage = 1;

me.load();
}
} else {

if (me.filters.getCount()) {
me.snapshot = me.snapshot || me.data.clone();
if(me.proxy.type != 'pagingmemory'){
me.data = me.data.filter(me.filters.items);
}
else{
var list = new Ext.util.MixedCollection(),
items = Ext.Array.clone(me.proxy.data);
for(i=0;i<items.length;i++){
list.add(Ext.create(me.model,items[i]));
}
me.data = list.filter(me.filters.items);
}
if (doLocalSort) {
me.sort();
} else {

me.fireEvent('datachanged', me);
me.fireEvent('refresh', me);
}
}
}
},