Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-9492 in 5.0.0b3.
  1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    15
    Vote Rating
    2
    navr84 is on a distinguished road

      0  

    Default Grid Filters Feature clear existing filters on store

    Grid Filters Feature clear existing filters on store


    Existing Filters on store getting cleared in 4.2 when a grid filter from the filter feature menu is applied.

    Consider the following store config:

    PHP Code:
    var store Ext.create('Ext.data.Store', {
                
    model 'Qreda.model.Test',
                
    remoteSort true,
                
    buffered true,
                
    pageSize 100,

                
    filters : [{
                    
    field 'testId',
                    
    type 'numeric',
                    
    comparison 'eq',
                    
    value 2
                
    }]
            }); 
    When the following store is used in a grid with filter feature, filtering from the menu clears the default filter on the grid.

    *EDIT BY SLEMMON
    User suggested override:
    Code:
    Ext.define("Foo.override.ux.grid.FiltersFeature", {
        override: "Ext.ux.grid.FiltersFeature",
    
    
    
    
        buildQuery: function (filters) {
            var p = {}, i, f, root, dataPrefix, key, tmp,
                len = filters.length;
    
    
    
    
            if (!this.encode) {
                for (i = 0; i < len; i++) {
                    f = filters[i];
                    root = [this.paramPrefix, '[', i, ']'].join('');
                    p[root + '[field]'] = f.field;
    
    
    
    
                    dataPrefix = root + '[data]';
                    for (key in f.data) {
                        p[[dataPrefix, '[', key, ']'].join('')] = f.data[key];
                    }
                }
            } else {
                tmp = [];
                for (i = 0; i < len; i++) {
                    f = filters[i];
                    tmp.push(Ext.apply({}, {
                        field: f.field
                    },
                        f.data));
                }
    
    
    
    
                /*
                 * NOTE: We have to add the existing filters on the store here manually.
                 */
                tmp.push.apply(tmp, Ext.decode(
                    this.store.getProxy().encodeFilters(this.store.filters.getRange())
                ));
    
    
    
    
                // only build if there is active filter
                if (tmp.length > 0) {
                    p[this.paramPrefix] = Ext.JSON.encode(tmp);
                }
            }
            return p;
        }
    });
    Last edited by slemmon; 15 Apr 2013 at 11:30 AM. Reason: included suggested code change

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    5,010
    Vote Rating
    183
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    I'm having some trouble building a test case to reproduce the issue. Would you be able to post a more complete code snippet to demonstrate the issue you're seeing?

  3. #3
    Sencha User mono blaine's Avatar
    Join Date
    Jul 2008
    Location
    Turkey
    Posts
    123
    Vote Rating
    8
    mono blaine will become famous soon enough

      0  

    Default


    When a store makes a request to the server with some filters defined through the Ext.ux.grid.FiltersFeature, any existing filters on the store are ignored, thus not sent with the request.

    I've been using the following override for a while, but you have to mess with the implementation of Ext.data.proxy.Server.encodingFilters a little bit. Because the serialization of store filters and FiltersFeature filters are a little different.

    Code:
    Ext.define("Foo.override.ux.grid.FiltersFeature", {
        override: "Ext.ux.grid.FiltersFeature",
    
    
        buildQuery: function (filters) {
            var p = {}, i, f, root, dataPrefix, key, tmp,
                len = filters.length;
    
    
            if (!this.encode) {
                for (i = 0; i < len; i++) {
                    f = filters[i];
                    root = [this.paramPrefix, '[', i, ']'].join('');
                    p[root + '[field]'] = f.field;
    
    
                    dataPrefix = root + '[data]';
                    for (key in f.data) {
                        p[[dataPrefix, '[', key, ']'].join('')] = f.data[key];
                    }
                }
            } else {
                tmp = [];
                for (i = 0; i < len; i++) {
                    f = filters[i];
                    tmp.push(Ext.apply({}, {
                        field: f.field
                    },
                        f.data));
                }
    
    
                /*
                 * NOTE: We have to add the existing filters on the store here manually.
                 */
                tmp.push.apply(tmp, Ext.decode(
                    this.store.getProxy().encodeFilters(this.store.filters.getRange())
                ));
    
    
                // only build if there is active filter
                if (tmp.length > 0) {
                    p[this.paramPrefix] = Ext.JSON.encode(tmp);
                }
            }
            return p;
        }
    });

  4. #4
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    5,010
    Vote Rating
    183
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

Thread Participants: 2

Tags for this Thread