【问题标题】:How to override refresh action in PagingToolbar如何覆盖 PagingToolbar 中的刷新操作
【发布时间】:2012-11-30 03:19:32
【问题描述】:

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

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

【问题讨论】:

    标签: extjs extjs4 extjs4.1


    【解决方案1】:
    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);
    }
    

    【讨论】:

      【解决方案2】:

      如果你只想做一次使用

      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 核心时都必须仔细检查以确保功能正常!

      【讨论】:

      • thnx,完全满足我的要求。
      • @ZakariaImtiaz 不客气 :) 您应该接受正确答案,并在投票数下方进行检查;)
      • @ZakariaImtiaz 大声笑 关心这一点总是好的,更重要的是,它有助于所有其他因您的问题而困惑的用户找出解决方案。但无论如何感谢您接受
      • 好吧。我试图在刷新后选择我的网格的第一行。为此,它是必要的。最后,我按照您的建议覆盖刷新方法,并将必要的代码放在 [me.store.loadPage(current);] 行之后。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-01
      • 1970-01-01
      • 2014-10-08
      • 2011-04-13
      • 2013-01-26
      • 1970-01-01
      • 2020-12-22
      相关资源
      最近更新 更多