Results 1 to 5 of 5

Thread: [Solved] displayMsg problem with grid's PagingToolbar...

  1. #1
    Ext User ritesh.kapse's Avatar
    Join Date
    May 2008
    Location
    Pune, India
    Posts
    120
    Vote Rating
    0
      0  

    Post [Solved] displayMsg problem with grid's PagingToolbar...

    Hi,

    When I remove a record from a grid's store, the paging tool bar doesn't update the displayMsg. Please see the screenshot attached.

    I am using the following code:-

    Code:
    gridStore.remove(record); //displayMsg as it is. i.e. Jobs 1 - 8 of 8
    grid.getBottomToolbar().updateInfo(); //displayMsg changes to Jobs 1 - 7 of 8
    The total value i.e.8 doesn't get updated !!!

    any help on this ?
    Attached Images Attached Images

  2. #2
    Ext User ritesh.kapse's Avatar
    Join Date
    May 2008
    Location
    Pune, India
    Posts
    120
    Vote Rating
    0
      0  

    Lightbulb am i going in the right way ?

    I used a simple overid to fix this...

    Code:
    Ext.PagingToolbar.override({
        updateInfo : function(){
                if(this.displayEl){
                    var count = this.store.getCount();
                    var msg = count == 0 ?
                        this.emptyMsg :
                        String.format(
                            this.displayMsg,
                            this.cursor+1, this.cursor+count, this.store.getCount() //line changed
                        );
                    this.displayEl.update(msg);
                }
            }    
    });
    Just replaced getTotalCount with getCount.

    Its displying the right count now

    Will it affect my other code ? Why was getTotalCount there in API insted of getCount ?

  3. #3
    Ext User ritesh.kapse's Avatar
    Join Date
    May 2008
    Location
    Pune, India
    Posts
    120
    Vote Rating
    0
      0  

    Red face Got it...

    it doesn't show proper total count for paging....

    still searching for solution

  4. #4
    Ext User ritesh.kapse's Avatar
    Join Date
    May 2008
    Location
    Pune, India
    Posts
    120
    Vote Rating
    0
      0  

    Lightbulb How about this ?

    Code:
    Ext.data.Store.override({
        removeCount :0,
        remove : function(record){
            var index = this.data.indexOf(record);
            this.data.removeAt(index);
            if(this.pruneModifiedRecords){
                this.modified.remove(record);
            }
            if(this.snapshot){
                this.snapshot.remove(record);
            }
            this.fireEvent("remove", this, record, index);
            this.removeCount++;
        },
        getTotalCount : function(){
            return this.totalLength ? (this.totalLength-this.removeCount): 0;
        },
        load : function(options){
            options = options || {};
            this.removeCount = 0;
            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;
            }
        },
    });
    anybody following this ?

    I thought it would be an important thread .

    A simple situation of gridStore.remove(record) with a paging toolbar

  5. #5
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    4
      0  

    Default

    Most people manage this by keeping the data source in sync with the grid. That is when you add/remove from the grid, do the same to the backend database and force a reload.

Posting Permissions

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