如何使用此id获取树节点div元素,ext:tree-node-id =" BSMNode1"

时间:2015-12-05 07:10:01

标签: extjs

在Extjs 3,Ext.tree.TreePanel中,使用这种类型的id ext生成树节点:tree-node-id =" BSMNode1"在div元素中。如何使用id获取div元素。我已经尝试过Ext.getCmp(' BSMNode1')和$ j('#BSMNode1')。但是,无法得到元素。请帮助我。谢谢

2 个答案:

答案 0 :(得分:0)

ExtJs 3.(我发布了这个作为答案,因为它包含一个解决方案)。我想将“删除”类添加到此div。

    <div ext:tree-node-id="web_6972" class="x-tree-node-el x-tree-node-leaf x-unselectable x-tree-node-leaf unpublished psave pview pedit pduplicate pnew pnew_modDocument pnew pnew_modSymLink pnew pnew_modWebLink pnew pnew_modStaticResource pqcreate pqupdate pdelete pundelete ppublish punpublish"
unselectable="on" id="extdd-277"><span class="x-tree-node-indent"><img alt="" src="/addons/manager/assets/ext3/resources/images/default/s.gif" class="x-tree-elbow-line"></span><i class="x-tree-ec-icon x-tree-elbow-end"></i><i class="icon tree-resource icon-web-6972 icon-parent-web-6971"
  unselectable="on" id="extdd-278"></i><a hidefocus="on" class="x-tree-node-anchor" href="#" tabindex="1"><span unselectable="on" id="extdd-279">CanDelete <span dir="ltr">(6972)</span></span></a></div>

这是JS

var x = Ext.DomQuery.selectNode('#web_6972'); // undefined

为我工作的是获取对树本身的引用(更高)并执行此操作:

 var rTree = Ext.getCmp('modx-resource-tree');
 var tNode = rTree.getNodeById('web_6972');
 tNode.getUI().addClass('deleted');

答案 1 :(得分:-1)

Ext.getCmp()用于选择ExtJS组件,以选择使用DOM元素Ext.DomQuery

Ext.DomQuery.selectNode('#BSMNode1');