How to override refresh action in PagingToolbar

Zakaria Imtiaz picture Zakaria Imtiaz · Dec 12, 2012 · Viewed 9.3k times · Source

I need to write some action based on the refresh button in the Paging toolbar. How can I override the doRefresh() method?

this.bbar=Ext.create('Ext.PagingToolbar', {
      store: store,
      displayInfo: true,
      displayMsg: 'Displaying records {0} - {1} of {2}',
      emptyMsg: "No topics to display" 
});

Answer

sra picture sra · Dec 12, 2012

If you just want to do is once use

Ext.create('Ext.PagingToolbar', {
      store: store,
      displayInfo: true,
      displayMsg: 'Displaying records {0} - {1} of {2}',
      emptyMsg: "No topics to display",
      doRefresh : function(){
         // Keep or remove these code
         var me = this,
             current = me.store.currentPage;

         if (me.fireEvent('beforechange', me, current) !== false) {
             me.store.loadPage(current);
         }
      }
});

or for all pagebars.

Ext.PagingToolbar.prototype.doRefresh = function() {
     // Keep or remove these code
     var me = this,
         current = me.store.currentPage;

     if (me.fireEvent('beforechange', me, current) !== false) {
         me.store.loadPage(current);
     }
}

Note that if you doing so you have to double check it each time you update the EXTJS core to ensure functionality!