javascript - Change view and remove element by Ext.Component.query
问题描述
I have a TabPanel like this:
Ext.application({
name : 'Fiddle',
launch : function() {
Ext.create('Ext.TabPanel', {
items: [
{
title: "",
reference: 'tabpanel',
itemId: 'tab1',
items: [{
itemId: 'firstTab',
xclass: 'viewClass'
}],
}, {
title: "",
reference: 'tab2',
layout: 'fit',
items: [{
xclass: "view",
}]
}
]
in the xclass component there is the path of a class where is defined the view. In the view should be a button, after tap on it, the view should refresh and show another class, for example the view should be defined by 'viewClass2' and not anymore by 'viewClass' I'm imaging a function triggered on button tap like this:
Ext.getCmp('tab1').remove('firstTab');
Ext.getCmp('tab1').add({
itemId: 'firstTab',
xclass: 'viewClass2'
})
BUT I must use itemId
and not id
so I cannot use "Ext.getCmp
" and i should use Ext.Component.query
but I don't know how to manage remove and add operations
解决方案
您必须首先获取组件的引用,然后将其删除。
Ext.create('Ext.TabPanel', {
id: 'myTabPanel',
items: [
{
title: "",
reference: 'tabpanel',
itemId: 'tab1',
items: [{
itemId: 'firstTab',
xclass: 'viewClass'
}],
}, {
title: "",
reference: 'tab2',
layout: 'fit',
items: [{
xclass: "view",
}]
}
];
var tabPanel = Ext.getCmp('myTabPanel');
var tab = tabPanel.getComponent("tab1");
// remove by id
tab.remove(tab.down("[itemId='firstTab']").id);
// remove by reference
tab.remove(tab.down("[itemId='firstTab']"));
推荐阅读
- pytorch - 从 CPU RAM 使用情况来看,直接在 GPU 上创建 Pytorch 变量似乎仍然首先在 CPU 上创建变量
- cmake - 如何从命令行使用自定义工具链构建基于 CLion 的 CMake 项目
- javascript - 为什么刷新后内容不显示
- linux - 使用 bash 脚本和两个参数获取位于 hdfs 中的 csv 文件的路径
- kdb - KDB+/Q:自定义最小最大缩放器
- python - 比较两个 csv 文件并输出更改
- javascript - 将 DIV 元素单击 3 次时替换为 Cookie 日志记录
- postgresql - Doctrine 查询结果为空,但生成的运行查询在 Postgres 中有效
- excel - 阻止用户实例化接口而不是其实现
- pastebin - 哪些关键字会触发 pastebin.com 上的验证码页面?