ExtJS Tree same parentNode

I am rendering a Tree using Jason array that i get from a jsp page. So the tree has root node and 3 nodes and each node has more than 5 children and some of the children has same id and same text. It renders properly and no issues in display.

I am trying to make the user select child nodes of only one type (one of 3 nodes). if the user selects any node which is not the sibling of already existing node then i just need to un check already checked nodes. This sounds pretty simple and i coded it. I basically compared the parent nodes(node.parentNode.id) of the checked node with the already checked nodes(tree.getCheckedNodes())

the problem is when i select children nodes which have same id and text my logic fails and they say that they have same parentNode.id even though they have different parentNode.id. Does the tree panel check for duplicate elements and assign them to same parentnode while loading? what is going here and how to fix this any ideas. thank you.

    Ext.onReady(function(){
  var tree = new Ext.tree.TreePanel({
    id: 'deficiencyTree',
    renderTo: 'MyTable',
    title: 'Deficiencies',
    height: 'auto',
    width: 525,
    useArrows: true,
    autoScroll: true,
    animate: true,
    enableDD: true,
    containerScroll: true,
    rootVisible: false,
    frame: false,
    root:{nodeType: 'async'},
    dataUrl: 'jsonFile.jsp',
    listeners: {     
      'checkchange': function (node, checked) {

      if (checked) {
          selNodes = tree.getChecked();  
           alert(selNodes);      
          Ext.each(selNodes, function (nodes) {

     alert("id values for node and nodes "+node.parentNode.id+" "+nodes.parentNode.id);

           if (nodes.parentNode.id != node.parentNode.id) 
           {
             nodes.getUI().toggleCheck();               
            }       

          });
        }     
        list.length = 0;
        iii = 0;
        selNodess = tree.getChecked();
        Ext.each(selNodess, function (nodes) {
          list[iii] = nodes.id;
          iii++;
        });
      }
    }
  });
  tree.getRootNode().expand(false);
});
share | edit

79% accept rate
 
Was this post useful to you?     

3 Answers

up vote 1 down vote accepted

As a semi-aside, ideally you should not be replicating node IDs at all (an ID should never be replicated, otherwise it isnt an ID). If you need the value that you are currently assigning to the ID field, add an additional attribute to the node and place it here- you can refer to this attribute when you need to. ExtJS isnt built to handle duplicate IDs for notes within the same tree very well at all.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值