Results 1 to 2 of 2

Thread: Dynamic change filter to store not reflected in Grid

  1. #1
    Sencha Premium User
    Join Date
    May 2013
    Location
    Netherlands
    Posts
    24

    Default Dynamic change filter to store not reflected in Grid

    I have a simple grid and store. I need to save the current sorting and filtering and apply them later dynamically. When I apply the sorting to the store the grid directry reflects the change (I see an Arrow in the column-header), but when I change the filtering on the store the changes are not reflected in the grid-columns. The store itself is filtered. (I use remote store)

    To get the actual sorting I use the following code:

    Code:
    var sortStates = [];
    if (store) store.getSorters().each(function (item, index) {
        sortStates.push(item.serialize());
    });
    
    To apply the sorting I use the following code:
    Code:
    var sorters = store.getSorters();
    for (var i = 0, sortState; sortState = sortStates[i]; i++) {
     sorters.add(new Ext.util.Sorter(sortState));
    }
    The grid directly reflects the sorting by showing the right arrow in the column-headers.

    I use simular code for the filtering:
    Code:
    //Get filters
    var filters = [];
    if (store) store.getFilters().each(function (item, index) {
        filters.push(item.serialize());
    });
    To apply the filter I use the following code:
    Code:
    for (var i = 0, fltState; fltState = filters[i]; i++) {
     filters.add(new Ext.util.Filter(fltState));
     fltChange = true;
    }

    But the filter is not reflected in the grid. The store itself is filtered..

    Any suggestion where to look?

    regards,

    Arno.

  2. #2

    Default

    3 Things :
    1. You can use the object literal syntax when adding, so you have a nice serializable version of your sorters and filters.
    2. When you filter for the second time, do you want to accumulate all existing filters or only the passed ones. May be you need to remove the filters before applying the new filters.
    3. Really nice thing is the chained store with your original store as source and all filters applied to the chained store, so your original store will be untouched when getting/filtering records.

    Greetings, Olli

Similar Threads

  1. 6.2.1 classic: Ext.window.Toast change log not reflected in docs/sources
    By fabricio.object in forum Sencha Documentation
    Replies: 3
    Last Post: 9 Jan 2017, 9:17 PM
  2. Replies: 1
    Last Post: 1 Apr 2015, 1:41 PM
  3. Adding dynamic filter on store for remote filtering
    By nacef_labidi in forum Sencha Architect 2.x: Help & Discussions
    Replies: 0
    Last Post: 16 May 2012, 2:33 AM
  4. Replies: 7
    Last Post: 23 Dec 2011, 3:54 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •