我正在尝试克隆 <thead>
Ext JS 中的元素并将其附加到 DOM 中的另一个位置。
我以这个 fiddle 为例:
作为该框架的新手,我在基础知识方面遇到了一些困难,并且不明白为什么这段代码对我不起作用。
最佳答案
Ext.select 方法返回 Ext.CompositeElement
的实例,该实例位于 Composite Pattern 后面。 ,意味着它是一个封装了多个相同类型元素的对象。要从 Ext.select
访问第一个表头 DOM 元素,您必须执行以下操作:
Ext.select('.data-grid thead').first().dom
我不太确定为什么 Ext.DomHelper.append
不起作用,但以下代码有效:
Ext.onReady(function() {
var hdr = Ext.select('.data-grid thead').first().dom,
cntr = Ext.select('.clone table').first().dom,
clone = Ext.clone(hdr);
cntr.appendChild(clone);
});
关于javascript - Ext JS 4 - 克隆节点并附加到 DOM 中的其他位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12728355/