EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: nyr_jack on October 29, 2012, 01:26:30 AM



Title: Big Problem about tree
Post by: nyr_jack on October 29, 2012, 01:26:30 AM
Codes:

html:
<ul id="basicTree" class="easyui-tree" style="height:200px;" data-options="url:'data/tree_data.json',checkbox:true,lines:true"></ul>
<ul id="targetTree" class="easyui-tree" style="height:200px;" data-options="checkbox:true,lines:true"></ul>

javascripts:

var checkedNodes = $('#basicTree').tree('getChecked');

for(var i = 0; i < checkedNodes.length; i++){
  //append every checked node to targetTree
/*
 parentNode = $('#basicTree').tree('getParent',checkedNodes.target);
 var t_node = $('#targetTree').tree('find',parentNode.id);
first problem is: there is no parent node of checkedNodes in targetTree, but when I use find method in targetTree , it can return node, it is wrong, how to solve?
*/
/*
$('#targetTree').tree('append',{
   parent:parentNode.target,
   data:[{
      id:checkedNodes.id,
      text:checkedNodes.text
   }]
});

it don't append this node to targetTree, but it append to basicTree.   
*/
}
Please help me ,it's hurry!


Title: Re: Big Problem about tree
Post by: nyr_jack on October 29, 2012, 01:41:44 AM
other question:

How to specify the parent node of a leaf node of basicTree ,and first append parent node to targetTree , and then append leaf node to targetTree??


Title: Re: Big Problem about tree
Post by: stworthy on October 29, 2012, 02:27:55 AM
Please refer to the sample below:
http://jsfiddle.net/jW4ST/
Select a node from the top tree and then click the 'append' link below to append nodes to the bottom tree.