【发布时间】:2013-04-17 10:49:42
【问题描述】:
通过单击显示菜单的按钮。 一旦我们选择了菜单,需要在其他菜单中动态更改项目。我没有为这个视图的任何组件定义 id,因为如果我给组件提供 id,它会给出错误重复 id found。 此视图在所有视图中都很常见,例如全局功能。在下面的代码中,两个项目:regionType 和项目:americaSubregionType 都来自常量文件。第一次我需要将这些数据显示为区域和子区域中菜单的默认项。一旦我从区域中选择项目,我需要在子区域菜单中动态更改项目。 所以我已经通过这种方式单击区域菜单,我已经为子区域项目分配了值:您可以在下面的代码中看到 americaSubregionType。 但它没有反映。旧数据本身显示来自常量文件的子区域菜单项。谁能告诉如何动态更改项目?如何在 extjs 中实现这一点?非常感谢。谢谢。
这是我的代码
{
xtype: 'button',
action: 'btnFilter',
cls: 'filterCls',
plain: true,
menu: {
items: [{
text: 'Region',
cls: 'filterMenuCls',
menu: {
plain: true,
cls: 'filterMenuCls',
listeners: {
click: function (menuitem, e, opt) {
var grid = Ext.getCmp('GridViewId');
grid.store.clearFilter();
grid.store.filter([{
property: "region",
value: e.text,
anyMatch: false,
exactMatch: true
}])
//This one i will retrieve from grid store and assign to americaSubregionType here will changesubregion value but it is not reflecting in visible view
americaSubregionType = [
'<b class="menuTitleCls">Choose a Vessel Type</b>', {
text: 'ABC',
cls: 'filterMenuCls'
}, {
text: 'Hello',
cls: 'filterMenuCls'
}]
}
},
items: regionType
}
}, {
text: 'SubRegion',
cls: 'filterMenuCls',
menu: {
plain: true,
cls: 'filterMenuCls',
action: 'Subbb',
listeners: {
click: function (menuitem, e, opt) {
}
},
items: americaSubregionType
}
}
}
}
}
常量文件数据
regionType = [
'<b class="menuTitleCls">Choose a Vessel Type</b>',
{
text: 'AMERICAS',
cls: 'filterMenuCls'
},
{
text: 'NORTH SEA',
cls: 'filterMenuCls'
},
{
text: 'SEA',
cls: 'filterMenuCls'
}
]
americaSubregionType = [
'<b class="menuTitleCls">Choose a Vessel Type</b>',
{
text: 'Brazil',
cls: 'filterMenuCls'
},
{
text: 'Mexico',
cls: 'filterMenuCls'
},
{
text: 'US',
cls: 'filterMenuCls'
}
]
【问题讨论】:
标签: extjs extjs4 extjs4.1 extjs-mvc