2014-12-19 34 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/