2012-08-30 85 views
2

我把PagingToolbar作爲我的網格的bbar。當工具提示出現時,它呈現在我的可見屏幕下方,這就是垂直滾動顯示的原因,但是當垂直滾動佔據視口的某個位置時,自動水平滾動也會顯示工具提示溢出。所以基本上我有2個問題。Extjs 4爲PagingToolbar禁用工具提示

  1. 垂直滾動顯示整個視口,但帶有bbar的網格僅在南部地區,網格已經垂直滾動自身。是否有某種配置來控制該行爲?

  2. 如何禁用PagingToolbar工具提示我有以下代碼不工作(網格定義,刪除不相關)。

 
initComponent: function() { 

     var me = this; 

     this.store = 'DevPlan'; 

var paging = Ext.create('Ext.PagingToolbar', { 
      store: this.store, 
      displayInfo: true, 
      displayMsg: 'Wyświetlono wnioski {0} - {1} z {2}', 
      emptyMsg: "Brak wniosków do wyświetlenia" 
     }); 

     Ext.each(paging.items.items, function(btn) { 
      if (btn.getXType() == 'button' && btn.tooltip != undefined) { 
       Ext.QuickTips.unregister(btn.getId()); 
      } 
     }); 

     this.bbar = paging; 

this.callParent(arguments); 

我想,也許上面的代碼不工作,因爲工具提示中尚未註冊或bacause分頁工具欄還沒有被渲染,所以我嘗試:

 
afterRender:function() { 

     this.callParent(); 

     var items = this.bbar.items.items; 
     Ext.each(items, function(btn) { 
      if (btn.getXType() == 'button' && btn.tooltip != undefined) { 
       console.log(btn.getId()); 
       Ext.QuickTips.unregister(btn.getId()); 
      } 
     }); 
    } 

但在這種代碼我得到this.bbar是未定義的。爲什麼?那麼bbar何時呈現?

+0

嘗試在您的視口中設置'autoscroll:false' – MMT

+0

我需要autoScroll爲true,有很多路徑可用於應用程序,有時需要autoScroll – patryks

+0

設置自動滾動到區域的容器i。e面板而不是視口 – MMT

回答

2

由於ExtJS4的BBAR僅僅是應用工具欄一小段路/項目,如底部停靠和初始化後,得到unsetted,看到

if (me.bbar) { 
    docked.push(initToolbar(me.bbar, 'bottom')); 
    me.bbar = null; 
} 

我想你可以做這樣(我希望這是一個事件,所以評論是):

afterrender: function(grid) { 
    // 'this' should not be accessible within a eventcallback! If it is you are within the class definition and should use this.on('beforerender', ...) after the callParent() instead!! 
    // callParent() should be called within the init of the class, not somewhere else! 
    // this.callParent(); 

    var pagebar = grid.down('pagingtoolbar'), 
     items = pagebar ? pagebar.items.items : [], 
     len = items.length, 
     i = 0; 
    // don't use each if it is not really necessary! 
    for(;i < len; i++) { 
     var item = items[i]; 
     if (item.getXType() === 'button' && item.tooltip != undefined) { 
      console.log(item.getId()); 
      Ext.QuickTips.unregister(item.getId()); 
     } 
    }); 
} 

編輯:根據您最後的評論

:你不應該重寫afterRen網格的德法,註冊自己的aftererender事件,而不是和initComponent(內做到這一點),然後調用父之後,寫在代碼expample的

編輯2註釋:

有是清除工具提示的每個按鈕上的私有方法。正如你可能知道私有方法仍然可以像任何其他方法一樣調用,但是可以在即將到來的框架版本中完全更改/刪除。他們中的大多數也無法在API中找到。您正在尋找的方法是clearTip()

在您想要刪除工具提示的每個按鈕實例上調用它。這應該工作。

我完全監督你的第一個問題:使用viewConfig: { autoScroll: false, scroll: false }

+0

感謝sra,我明白了爲什麼bbar爲null,但爲什麼不能我註銷afterRender覆蓋工具提示?我用'this.down('pagingtoolbar')'和'console.log(item.getId())'測試了我的代碼現在返回所有的id。仍然取消註冊(btnid)不起作用 – patryks

+0

和this.callParent();在afterRender覆蓋只是調用父母的afterRender函數,不是嗎? – patryks

+0

@Patryk Sosinski後編輯 – sra

0

你應該考慮從視刪除滾動行爲使用autoScroll: false或從電網禁用它你可以這樣做

{ 
dock : 'bottom', 
xtype : 'pagingtoolbar', 
store : store, 
pageSize : 25, 
displayInfo : true, 
firstText:null, 
prevText:null, 
nextText:null, 
lastText:null, 
refreshText:null, 
....