PDA

View Full Version : Column filter doesn´t filter beyond pagesize.



Throstur
12 Mar 2013, 2:02 AM
Version 4.1.1a
Column filtering does not filter beyond pagesize.
Is this a bug or am I doing something wrong?
I do not want to increase the page size
I need to have it buffered.



// typical column definition
col = {.. filter: {type: "string"}... };
...
var filters = {
ftype: 'filters',
autoReload: false,
local: true // using local filtering
};


var model = Ext.define('tablemodel',{
extend: 'Ext.data.Model',
idProperty: 'id',
fields: headers
});


var proxy = Ext.create('Ext.ux.data.PagingMemoryProxy', {
data: rows,
model: 'tablemodel',
reader: {
type:'array'
}
});


var row_data = Ext.create('Ext.data.ArrayStore', {
storeId:"row_store",
autoDestroy: true,
autoSync: false, //sync with proxy
buffered: true, // load page data in grid store
clearOnPageLoad: false, // clear the page (grid store) on new page
proxy:proxy,
pageSize: 100,
remoteSort: true,
remoteFilter: true,
sortOnFilter: false,
purgePageCount: 0,
model: 'tablemodel',
listeners: {
...
}
});
...
this.grid = Ext.create('Ext.grid.Panel', {
store: row_data,
region: 'center',
border: false,
stripeRows: true,
height: 642,
columnLines: true,
maxHeight: 642,
verticalScroller: {
xtype: 'paginggridscroller',
scrollToLoadBuffer: 200,
trailingBufferZone: 15,
leadingBufferZone: 10
},
columns: grid_cols,
multiSelect: true,
selType: 'rowmodel',
features: [filters],

listeners: {
...
}
});


},


Note... using this filter will filter the whole store with no problems, but I want the column filters to work the same


var regex = new RegExp(".*"+searchStringEntered+".*");

var filterFunc = function(item){
for(var i=0;i<item.raw.length;i++)
{
if(regex.test(item.raw[i]))
return true;
}
}
return false;

store.filter({filterFn:filterFunc});


I´ve tried store.guranteerange(..) but that does not go beyond the pagesize.
Any help appreciated.

Throstur
13 Mar 2013, 6:10 AM
Still trying to figure this out..
Updated to 4.1.3 and the problem persists.
Filtering was working fine in 4.1.0.

Throstur
13 Mar 2013, 6:48 AM
Looking further into
examples\ux\grid\FiltersFeature.js
and comparing 4.1.1a and 4.1.0

4.1.1a uses filterBy and sort
I expect it only filters the buffered rows in the grid store (not the whole dataset)

store.filterBy(me.getRecordFilter());
store.sort();




in 4.1.0 filters added and the store loaded, thus the whole dataset is filtered, which is much much better


store.filters.add( { filterFn: me.getRecordFilter() } );
store.load();



So is this a bug?

grpbhb
13 Mar 2013, 7:38 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);
}
}
}
},

mcouillard
13 Sep 2013, 9:54 AM
Thought I had the same issue in 4.2.2 beta but I simply had to turn remoteFilter and remoteSort to true to make filtering affect all pages. Whew!

store...
remoteFilter: true,
remoteSort: true,
proxy: {
type: 'memory'
enablePaging: true
}