gpt4 book ai didi

javascript - extjs3.4 : How to access items in a panel that do not have id/itemId

转载 作者:行者123 更新时间:2023-12-03 11:23:55 24 4
gpt4 key购买 nike

我刚刚开始使用 ExtJS 3.4 版本。当没有分配 id 或 itemId 时,我不确定如何访问面板中的项目。我之前使用过 Ext JS 4.2,但现在需要使用 3.4 版本。

就我而言,我在这里使用边框布局。我在东部区域有一个树面板,在中心区域有一个选项卡面板。我想根据单击的树节点使用网格或表单动态更新中心区域。

这是我的选项卡面板代码

{
xtype : 'tabpanel',
title : 'Center Panel',
width : 200,
region : 'center',
items:[gridpnl]
}

这是我尝试过的完整代码 第一个 ExtJs 页面 Ext.onReady(函数(){

        Ext.namespace('Class');
Class.create = function() {
return this.init(config);
}
};

Ext.namespace('FirstOOPS');
FirstOOPS = Class.create();
FirstOOPS.prototype = {
init: function (config) {

var store= new Ext.data.ArrayStore({
fields: [{name: 'C1'},{ name: 'C3'}, {name: 'C5'}]
});
var myData= [['abcdC11','C3','C5'],['asdf','C3_asdf','C5_asdf']]
store.loadData(myData);

var gridpnl= new Ext.grid.GridPanel({
layout: 'fit',
height: 500,
width: 500,
store: store,
columns:[
{header: "C1", dataIndex: 'C1'},
{header: "C3", dataIndex: 'C3'},
{header: "C5", dataIndex: 'C5' }
]
});

var mainPanel = new Ext.Panel({
layout : 'border',
items : [
{
region: 'east',
collapsible: true,
title: 'Navigation',
xtype: 'treepanel',
width: 200,
autoScroll: true,
split: true,
loader: new Ext.tree.TreeLoader(),
root: new Ext.tree.AsyncTreeNode({
expanded: true,
children: [{
text: 'Grid',
leaf: true
}, {
text: 'Form',
leaf: true
}]
}),
rootVisible: false,
listeners: {
click: function(n) {

if(n.text=='Grid'){
Ext.Msg.alert(n.text);

}
}
}
},{
xtype : 'tabpanel',
title : 'Center Panel',
width : 200,
region : 'center',
items:[gridpnl]

}
]
});
new Ext.Viewport({
layout : 'fit',
items : [mainPanel]
});
}
};
var firstObj = new FirstOOPS();
});
</script>
</body>
</html>

有人可以告诉我如何在没有 id 的情况下访问它,以便我可以动态更新选项卡面板或根据树节点单击创建新选项卡。

提前致谢

最佳答案

您可以使用以下代码来访问 tabpanel,而无需使用 id 或 items id

this.up().items.items[1]

为了测试上面的代码,我通过以下代码提醒选项卡面板的标题

      alert(this.up().items.items[1].title);

它将提醒选项卡面板的标题

关于javascript - extjs3.4 : How to access items in a panel that do not have id/itemId,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26997176/

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