Zakaria Imtiaz
Zakaria Imtiaz

Reputation: 539

How to override refresh action in PagingToolbar

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" 
});

Upvotes: 7

Views: 9976

Answers (2)

Zakaria Imtiaz
Zakaria Imtiaz

Reputation: 539

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

     if (me.fireEvent('beforechange', me, current) !== false) {
        me.store.loadPage(1, {                                      
            callback: function (records, operation, success) {  
                Ext.getCmp('educationGrid').getSelection(records, operation, success);                                      
            }
        });
     }
  }

});

...................................

getSelection: function(records, operation, success){
    var grid= Ext.getCmp('educationGrid'); //my grid
    grid.getView().select(0);
}

Upvotes: 5

sra
sra

Reputation: 23973

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!

Upvotes: 14

Related Questions