[英]Do getElementById for an HTML element inside a ExtJS panel
I need to fetch an HTML element from an ExtJS panel and replace it with another HTML element.我需要从 ExtJS 面板中获取一个 HTML 元素并将其替换为另一个 HTML 元素。
I have a normal ExtJS panel -> rptPanel, whose innerHTML is copied to another panel -> outputDataPanel.我有一个普通的 ExtJS 面板 -> rptPanel,它的 innerHTML 被复制到另一个面板 -> outputDataPanel。
Please refer the code below.请参考下面的代码。
var html = rptPanel.body.dom.innerHTML;
me.outputDataPanel.insert(me.itemIndex,{
html : html,
border : 0,
cls : 'htmlView_font_higher htmlView_font',
style : 'margin: 10px 0px 20px 0px; width: 100%;'
});
Now, I need to fetch an HTML element inside outputDataPanel
(something like getElementById('table_data')
on outputDataPanel
) and replace it with another HTML element.现在,我需要获取内部的HTML元素outputDataPanel
(类似getElementById('table_data')
上outputDataPanel
),并与另一个HTML元素替换它。
Can anyone please help?有人可以帮忙吗?
试试这个(我想这不是 Sencha 的最佳实践):
outputDataPanel.getEl().down('#table_data')
You can set an ID to that element and get it like so:您可以为该元素设置一个 ID 并像这样获取它:
// by id
var el = Ext.get("myDivId");
// by DOM element reference
var el = Ext.get(myDivElement);
// by id
var el = Ext.getDom('myDivId');
// by DOM element reference
var el = Ext.getDom(myDivElement);
Alternative way would be:替代方法是:
set an item-id to that element, lets say it's an item in the panel:为该元素设置一个 item-id,假设它是面板中的一个项目:
{
'text': 'myBTN',
iconCls: 'sprite',
disabled: true,
itemId: 'btn1',
handler: function(btn,e){
self.myFunction();
}
}
later on the code look for it by this.down("#btn1")稍后在代码中通过 this.down("#btn1") 查找它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.