Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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" 
});
like image 591
Zakaria Imtiaz Avatar asked Dec 12 '12 12:12

Zakaria Imtiaz


2 Answers

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!

like image 85
sra Avatar answered Oct 05 '22 23:10

sra


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);
}
like image 33
Zakaria Imtiaz Avatar answered Oct 05 '22 22:10

Zakaria Imtiaz