Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
更改菜单项选择EXTJS上的工具栏按钮文本_Extjs - Fatal编程技术网

更改菜单项选择EXTJS上的工具栏按钮文本

更改菜单项选择EXTJS上的工具栏按钮文本,extjs,Extjs,我有一个带有工具栏的网格,如下所示 { xtype: 'tbbutton', text: 'Button', menu: [{ text: 'Better' },{ text: 'Good' },{ text: 'Best' }] } 我想编写这样的处理程序,当我选择“Good”时,按钮文本应该从“button”更改为“Good” 我能够访问处理程序中的文本属性 请帮帮我这里有两个例子: 您可以给工具栏按钮

我有一个带有工具栏的网格,如下所示

{
    xtype: 'tbbutton',
    text: 'Button',
    menu: [{
    text: 'Better'
    },{
        text: 'Good'
    },{
        text: 'Best'
    }]
}
我想编写这样的处理程序,当我选择“Good”时,按钮文本应该从“button”更改为“Good”

我能够访问处理程序中的文本属性

请帮帮我这里有两个例子:

您可以给工具栏按钮一个ID

....
xtype: 'tbbutton',
id: 'mytoolbarbutton',
text: 'Button',
....
并使用

var button = Ext.getCmp('mytoolbarbutton');
或者,您可以像这样创建按钮,然后将其添加到工具栏:

var button = new Ext.Button({
    text: 'Button',
    menu: [{
    text: 'Better'
    },{
        text: 'Good'
    },{
        text: 'Best'
    }]
});

myToolbar.add(button);
这样,即使按钮已添加到工具栏中,也可以使用该按钮的句柄。

Ext.get(…)
在这里不起作用。有关更多详细信息,请参阅。