2014-12-19 22 views
0

我有一個面板,如下所示:的ExtJS的setTitle()不更新面板標題

Ext.define('TestPanel', { 
    extend: 'Ext.panel.Panel', 
    alias: 'widget.testPanel', 
id: 'testerPanel', 
title: 'oldTilte', 
//other code 
}); 

我有不同視圖的控制器,其中我希望更新的面板標題:

var grid = Ext.getCmp('testerPanel'); 
grid.setTitle('newTitle'); //doesn't update the title 

//tried with including ref or view in the controller 
this.getTestPanel().setTitle('newTitle'); //this didn't update it either 

如何更新面板標題?此外,對於上述嘗試,如果我打印console.info(grid)console.info(this.getTestPanel()),我總是看到在控制檯輸出更新的標題,但UI本身保持不變

+0

肯定有網格的其他實例?您使用getCmp來獲取網格的實例,並且總是有風險的,因爲您必須確保這些ID是唯一的。改用ComponentQuery。 – Saki 2014-12-19 09:02:15

回答

1

查看下面的Jsfiddle演示爲您的要求,它工作。具有初始標題的網格。網格工具欄包含一個按鈕'更改標題'點擊查看您需要的解決方案。

this.up('grid').setTitle('New Grid Title');

這是上面的工作演示:http://jsfiddle.net/PhAbR/83/