1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    28
    Answers
    1
    Vote Rating
    1
    PKK is on a distinguished road

      1  

    Default Unanswered: Problems with filtering

    Unanswered: Problems with filtering


    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:
    Code:
    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:
    Code:
    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?

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,080
    Answers
    674
    Vote Rating
    467
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      1  

    Default


    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.

    Scott.

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    28
    Answers
    1
    Vote Rating
    1
    PKK is on a distinguished road

      0  

    Default


    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.

  4. #4
    Sencha User
    Join Date
    Jun 2011
    Posts
    28
    Answers
    1
    Vote Rating
    1
    PKK is on a distinguished road

      0  

    Default


    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:

    Code:
    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:

    Code:
    grid.filters.addFilter({dataIndex: 'd1', type: 'string', value: 'NO'});
    grid.filters.reload();
    puts a text NO, but leaves the checkbox unchecked. Trying to set:

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

    Code:
    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:

    Code:
    var filter_data = '[{dataIndex:"d2",type:"numeric",comparison:"lt",value:2},{dataIndex:"d1",type:"string",value:"NO"}]';
    // grid configs etc
    
    grid.filters.addFilters(filter_data);
    grid.filters.reload();
    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.

  5. #5
    Ext JS Premium Member
    Join Date
    Sep 2009
    Posts
    3
    Vote Rating
    1
    awood is on a distinguished road

      1  

    Default


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

  6. #6
    Sencha User
    Join Date
    Nov 2012
    Posts
    6
    Vote Rating
    0
    GGG65 is on a distinguished road

      0  

    Default


    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.

Thread Participants: 3