ExtJS Tree same parentNode

39951 단어 ExtJs

ExtJS Tree same parentNode


up vote

down vote
favorite
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
asked 
Oct 28 '10 at 23:47

Suman Kumar
167
십이
79% accept rate
 
Was this post useful to you?     

3 Answers


active
oldest
votes
up vote

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.

좋은 웹페이지 즐겨찾기