amr*_*rk7 5 grid extjs panel title extjs4.1
我有这样的网格面板
Ext.define('sCon.view.SalesGrid',{
extend: 'Ext.grid.GridPanel',
title: 'Sales Data',
//other params
initComponent: function(){
this.callParent(arguments);
}
});
Run Code Online (Sandbox Code Playgroud)
在点击事件上,我想更改此面板的标题.我在控制器内的代码看起来像这样.
Ext.define('sCon.controller.SalesGridController', {
extend: 'Ext.app.Controller',
views: ['SalesGrid'],
// other handlers
changeTitle: function(newTitle){
this.getView('SalesGrid').setTitle('title_changed');
}
Run Code Online (Sandbox Code Playgroud)
目前它说它没有setTitle()的功能.但是文档说网格面板有setTitle()函数.我也尝试使用'title'变量更改标题
changeTitle: function(newTitle){
this.getView('SalesGrid').title = 'title_changed';
Run Code Online (Sandbox Code Playgroud)
既不起作用..请帮忙.
UPD: 以下是refsSencha for ExtJS 4.1的一些文档.
使用refs控制器的属性来获取对任何组件的引用.
在你的例子中:
Ext.define('sCon.view.SalesGrid',{
extend: 'Ext.grid.GridPanel',
title: 'Sales Data',
alias: 'widget.salesgrid',
//other params
initComponent: function(){
this.callParent(arguments);
}
});
Run Code Online (Sandbox Code Playgroud)
在Controller中添加:
refs: [
{ ref: 'salesGrid', selector: 'salesgrid', },
]
Run Code Online (Sandbox Code Playgroud)
然后,您可以从控制器中的任何位置访问SalesGrid视图,如this.getSalesGrid();方法.
在你的情况下:
changeTitle: function(newTitle){
this.getSalesGrid().setTitle('title_changed');
}
Run Code Online (Sandbox Code Playgroud)