1. #1
    Sencha User
    Join Date
    Mar 2008
    Posts
    566
    Vote Rating
    0
    moegal is on a distinguished road

      0  

    Default clearing baseParams?

    clearing baseParams?


    How can I clear or remove baseParams?

    gridstore.baseParams = {}; doesn't seem to work. For now we are loopinhg thru them all and setting them to empty. Is there a method for this?

    Thanks, Marty

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,505
    Vote Rating
    52
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    It could be a problem of the Store class corrupting the config object which you pass to load or reload.

    It actually mutates any params object that you have in a config which you pass to load or reload.

    How is your code using these methods?

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,505
    Vote Rating
    52
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    The code has

    Code:
        load : function(options){
            options = options || {};
            if(this.fireEvent("beforeload", this, options) !== false){
                this.storeOptions(options);
                var p = Ext.apply(options.params || {}, this.baseParams);
                if(this.sortInfo && this.remoteSort){
                    var pn = this.paramNames;
                    p[pn["sort"]] = this.sortInfo.field;
                    p[pn["dir"]] = this.sortInfo.direction;
                }
                this.proxy.load(p, this.reader, this.loadRecords, this, options);
                return true;
            } else {
              return false;
            }
        },
    
        /**
         * <p>Reloads the Record cache from the configured Proxy using the configured Reader and
         * the options from the last load operation performed.</p>
         * <p><b>It is important to note that for remote data sources, loading is asynchronous,
         * and this call will return before the new data has been loaded. Perform any post-processing
         * in a callback function, or in a "load" event handler.</b></p>
         * @param {Object} options (optional) An object containing loading options which may override the options
         * used in the last load operation. See {@link #load} for details (defaults to null, in which case
         * the most recently used options are reused).
         */
        reload : function(options){
            this.load(Ext.applyIf(options||{}, this.lastOptions));
        },
    Try an override

    Code:
    Ext.override(Ext.data.Store, {
        load : function(options){
    //      Use a copy of what the caller passed
            options = Ext.apply({}, options);
            if(this.fireEvent("beforeload", this, options) !== false){
                this.storeOptions(options);
                var p = Ext.apply(options.params || {}, this.baseParams);
                if(this.sortInfo && this.remoteSort){
                    var pn = this.paramNames;
                    p[pn["sort"]] = this.sortInfo.field;
                    p[pn["dir"]] = this.sortInfo.direction;
                }
                this.proxy.load(p, this.reader, this.loadRecords, this, options);
                return true;
            } else {
              return false;
            }
        },
    
        /**
         * <p>Reloads the Record cache from the configured Proxy using the configured Reader and
         * the options from the last load operation performed.</p>
         * <p><b>It is important to note that for remote data sources, loading is asynchronous,
         * and this call will return before the new data has been loaded. Perform any post-processing
         * in a callback function, or in a "load" event handler.</b></p>
         * @param {Object} options (optional) An object containing loading options which may override the options
         * used in the last load operation. See {@link #load} for details (defaults to null, in which case
         * the most recently used options are reused).
         */
        reload : function(options){
    //      Use a copy of what the caller passed
            options = Ext.apply({}, options);
            this.load(Ext.applyIf(options, this.lastOptions));
        }
    });

  4. #4
    Sencha User
    Join Date
    Mar 2008
    Posts
    566
    Vote Rating
    0
    moegal is on a distinguished road

      0  

    Default


    Thanks. I am just setting the baseParams on the store and then loading the grid. I have a search form that I use to set new baseParams. I need a way to clear them to reset the grid. Seems your code works fine to clear the baseParams but the original params are still getting posted to the page along with start and limit.

    Any way to remove them from the post?

    Thanks, Marty

    Also, thanks for the fast reply!

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,505
    Vote Rating
    52
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    So, where's your code that's going wrong?

  6. #6
    Sencha User
    Join Date
    Mar 2008
    Posts
    566
    Vote Rating
    0
    moegal is on a distinguished road

      0  

    Default


    Code:
    {
    			text: 'Reset',
    			handler: function(){
    				gridstore.baseParams = {};
    				grid.getSelectionModel().clearSelections();
    				gridstore.reload();
    			}
    }

  7. #7
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,505
    Vote Rating
    52
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    reload.

    You are asking it to reload

    Not to load.

  8. #8
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,505
    Vote Rating
    52
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Quote Originally Posted by TFM"
    Reloads the Record cache from the configured Proxy using the configured Reader and the options from the last load operation performed.
    http://extjs.com/deploy/dev/docs/?cl...&member=reload

  9. #9
    Sencha User
    Join Date
    Mar 2008
    Posts
    566
    Vote Rating
    0
    moegal is on a distinguished road

      0  

    Default


    that did it. Thanks! I appreciate your help.

    Marty

Thread Participants: 1