View Full Version : Problems with filtering

14 Jun 2012, 11:31 PM
I'm building up a remote filtering for a buffered grid and I've run in a couple of problems. First of all, I'm able to set to filter configuration a row:

filters: [
{type: 'string', value: 'YES', dataIndex: 'col1'}
but I can't set a value to a numeric field. I have tried several different ways, like:

filters: [
{type: 'numeric', comparison: 'gt', value: 0, dataIndex: 'col1'}
but this has no effect. The purpose of this is that the server remembers the filtering and it is restored as the grid loads again.

A second thing is that when I initially load the grid, the filtering data is not sent as a parameter in GET method. I presumed that filters would behave like sort and everything would work, but that is not the way it is.

How to overcome these two problems?

15 Jun 2012, 6:26 AM
If this is remote, then can you simply filter the data at the server level? This also sends less data over the pipe.

Local Filtering/Sorting is not supported on buffered store.


17 Jun 2012, 8:38 PM
The filter is done remotely, and that part is fine. But, when the web service user comes back to the specific site and the same view (filtering + sorting) is wanted, the problems arise. I am able to show the right data ofc, but the point is that I am not able to set the columns' filtering (the visible part to the user, what ever is the right phrase for this) to the right settings, they are always blank (on numeric data). So, this leads to a situation, where the user can not know which column is actually filtered and how, and it is also impossible to reset the filtering, except blindly trying to put some filtering to columns and then erasing it.

Initially I assumed that if I am setting on the right filter settings to the source code of the page, the filtering would be "loaded" to the column headers and it would look and behave correctly. But now the only options would be always to reset the filters from user's point of view. I tried addFilter() and addFilters() methods too, but when working on a buffered grid and remote filtering, they seem not to do almost anything. I might be wrong here and might have used these erratically, for javascript usually gives me a blistering headache. But there is not much information available of this kind of setup, so I am quite confused.

I would also like to point out, that if I generate sorting setting to the page, this parameter working correctly and the sorting setting is sent with the get method. Filter settings do not, which is quite illogical.

17 Jun 2012, 10:21 PM
As my previous message was quite a mess, I continue with a different approach. Here are some cases I have tried and which give different results:

filters: [
{type: 'string', dataIndex: 'd1', value: 'NO'

displays NO and the filter checkbox is checked in column menu. For type numeric this does not work. Even though the filtering is now visible, using a filter clearing button I made for debugging doesn't have any effect on this preset filtering, unless I first go and take a look at this header and the filter field. Using instead:

grid.filters.addFilter({dataIndex: 'd1', type: 'string', value: 'NO'});

puts a text NO, but leaves the checkbox unchecked. Trying to set:

grid.filters.addFilter({dataIndex: 'd2', type: 'numeric', comparison: 'lt', value: 2});

gives an error:

invalid 'in' operand data

field.setValue(key in data ? data[key] : '');

Using addFilters() confuses me the most, I can not make it to do anything. I'm trying to load the object data in a literal way, as in:

var filter_data = '[{dataIndex:"d2",type:"numeric",comparison:"lt",value:2},{dataIndex:"d1",type:"string",value:"NO"}]';
// grid configs etc

I'm probably doing everything wrong here, for this is so weird. But I can't find any help from googling or anywhere, so any help is truly appreciated.

Sending even this preset filtering as a get message in the beginning would be a plus, but it is not a must in my use case. Displaying it right, instead, is obligatory.

24 Oct 2012, 5:58 AM
Try this:

grid.filters.addFilter({dataIndex: 'd2', type: 'numeric', value: {'lt': 2}});

1 Aug 2013, 1:58 PM
For anyone else running into this problem, awood's answer worked to resolve this problem for me (I had exactly the issue the original poster reported). And I can find no example in the docs that demonstrates this... so thank you awood.