如何在PagingToolbar中覆盖刷新操作

Zak*_*iaz 7 extjs extjs4 extjs4.1

我需要根据分页工具栏中的刷新按钮编写一些操作.我该如何覆盖该doRefresh()方法?

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

sra*_*sra 12

如果你只是想做就是一次使用

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);
         }
      }
});
Run Code Online (Sandbox Code Playgroud)

或所有的页面栏.

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);
     }
}
Run Code Online (Sandbox Code Playgroud)

请注意,如果您这样做,则每次更新EXTJS核心时都必须仔细检查它以确保功能!


Zak*_*iaz 5

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);                                      
            }
        });
     }
  }
Run Code Online (Sandbox Code Playgroud)

});

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

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