gpt4 book ai didi

extjs 更改事件的面板标题

转载 作者:行者123 更新时间:2023-12-04 17:02:24 24 4
gpt4 key购买 nike

我有一个像这样的网格面板

Ext.define('sCon.view.SalesGrid',{
extend: 'Ext.grid.GridPanel',
title: 'Sales Data',

//other params

initComponent: function(){
this.callParent(arguments);
}
});

在单击事件中,我想更改此面板的标题。我在 Controller 中的代码如下所示。
Ext.define('sCon.controller.SalesGridController', {
extend: 'Ext.app.Controller',
views: ['SalesGrid'],

// other handlers

changeTitle: function(newTitle){
this.getView('SalesGrid').setTitle('title_changed');
}

目前它说它没有像 setTitle() 这样的函数。但是文档说网格面板具有 setTitle() 功能。我还尝试使用“title”变量更改标题,例如
 changeTitle: function(newTitle){
this.getView('SalesGrid').title = 'title_changed';

两者都不起作用.. 请帮忙。

最佳答案

更新: Here是一些 refs来自 Sencha 的 ExtJS 4.1 文档。

使用 refs您的 Controller 的属性以获取对任何组件的引用。

在你的例子中:

Ext.define('sCon.view.SalesGrid',{
extend: 'Ext.grid.GridPanel',
title: 'Sales Data',

alias: 'widget.salesgrid',

//other params

initComponent: function(){
this.callParent(arguments);
}
});

在 Controller 中添加:
refs: [
{ ref: 'salesGrid', selector: 'salesgrid', },
]

然后您可以从 Controller 中的任何位置访问您的 SalesGrid View ,例如 this.getSalesGrid();方法。

在你的情况下:
changeTitle: function(newTitle){
this.getSalesGrid().setTitle('title_changed');
}

关于extjs 更改事件的面板标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12246542/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com