如何覆盖PagingToolbar中刷新操作的动作

7

我需要编写一些与分页工具栏中的刷新按钮相关的操作。我该如何重写doRefresh()方法?

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

14

如果您只想做一次使用

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

或者适用于所有页面条。

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

请注意,如果您这样做,每次更新EXTJS核心以确保功能性,您都需要仔细检查它两次!


谢谢,正好满足我的要求。 - Zakaria Imtiaz
@ZakariaImtiaz 不用谢 :) 你应该在投票数字下面接受正确的答案,打勾表示接受。 - sra
@ZakariaImtiaz 哈哈,注意这点总是很好的,更重要的是,这有助于所有遇到你问题的其他用户找出解决方案。无论如何,感谢您的接受。 - sra
好的。我试图在刷新后选择我的网格的第一行。为此需要这样做。最终,我按照您的建议覆盖了刷新方法,并在[me.store.loadPage(current);]行之后放置了必要的代码。 - Zakaria Imtiaz

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

});

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

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接