EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: nyr_jack on October 24, 2012, 07:00:44 PM



Title: How to dynamic generate tree
Post by: nyr_jack on October 24, 2012, 07:00:44 PM
Code first:
1.<ul id="orgResTree" class="easyui-tree" style="height:200px;" data-options="url:'data/orgstructResourceTree_data.json',checkbox:true,lines:true"></ul>
2.<ul id="seldOrgTree" class="easyui-tree" style="height:200px;" data-options="checkbox:true,lines:true"></ul>

First there is a tree "orgResTree", When I click some nodes of this tree checked and click button,  these checked nodes are added to tree "seldOrgTree" to auto generate new tree. checked nodes maybe has children, I don't know how to do, please help!


Title: Re: How to dynamic generate tree
Post by: stworthy on October 25, 2012, 06:16:37 AM
Call 'getData' method from your first tree to get the selected node data, and then call 'append' method to append these data to your second tree.
Code:
var node = $('#orgResTree').tree('getSelected');
var data = $('#orgResTree').tree('getData', node.target);  // get the tree node data
$('#seldOrgTree').tree('append',{
  parent: ...,  // specify the parent node to be appended
  data: [data]
});