EasyUI Forum

General Category => General Discussion => Topic started by: azizkhani on January 02, 2015, 08:08:48 AM



Title: how to reload async tree
Post by: azizkhani on January 02, 2015, 08:08:48 AM
i use tree in async ,
after user add new node to tree i want to reload parent node again and fetch data from server.
how can do it?
plz


Title: Re: how to reload async tree
Post by: stworthy on January 02, 2015, 08:36:02 AM
Please pass the parent node element to the 'reload' method.
Code:
var p = ...  // get your parent node
$('#tt').tree('reload', p.target);  // reload the parent node


Title: Re: how to reload async tree
Post by: azizkhani on January 03, 2015, 08:36:48 AM
Please pass the parent node element to the 'reload' method.
Code:
var p = ...  // get your parent node
$('#tt').tree('reload', p.target);  // reload the parent node

when node state in open it is not work
i change state to closed and reload but again not work
var selectedNode = $('#tree').tree('getSelected');
$('#tree').tree('update', {
   target: selectedNode.target,
   state: 'closed'
});
$('#tree').tree('reload',selectedNode.target);

 ??? ??? ???


Title: Re: how to reload async tree
Post by: stworthy on January 03, 2015, 08:37:16 PM
Please open this example http://www.jeasyui.com/tutorial/tree/tree2_demo.html and then run the code below in your browser's console.
Code:
$('#tt').tree('reload',$('#tt').tree('getRoot').target);

You will see the root node is reloaded successfully.


Title: Re: how to reload async tree
Post by: azizkhani on January 04, 2015, 07:35:32 AM
Please open this example http://www.jeasyui.com/tutorial/tree/tree2_demo.html and then run the code below in your browser's console.
Code:
$('#tt').tree('reload',$('#tt').tree('getRoot').target);

You will see the root node is reloaded successfully.


yes root node is reloaded but if you add new node to node 2 in this page and want to reload node 2 to show children it is not work
because state is open ;


Title: Re: how to reload async tree
Post by: stworthy on January 04, 2015, 09:21:13 AM
Please notice that you are loading tree nodes from remote server. If you call 'append' method to append tree nodes. These appended nodes will not be saved to your server. You must do some saving action to let the server return the correct data back to the browser.


Title: Re: how to reload async tree
Post by: azizkhani on January 05, 2015, 07:28:10 AM
Please notice that you are loading tree nodes from remote server. If you call 'append' method to append tree nodes. These appended nodes will not be saved to your server. You must do some saving action to let the server return the correct data back to the browser.


that is right
 i add node in remote server (ajax ) and want reload just this node to see children,i will not reload root node because
1)my tree have more than 200,000 record  and it is bad performance
2)it is not good   for user that add node to level 3 and root node refresh and user will again open root again open level 2 to see node that create from client ??? ??? ??? ???


Title: Re: how to reload async tree
Post by: stworthy on January 05, 2015, 08:59:57 AM
How do you add new nodes to the tree? In fact you can call 'append' method to append new nodes to a specified node and then post these added nodes to your server. At any time you also can call 'reload' method to refresh the children nodes of a parent node.

If your issue continues, please provide an example or a link page to demonstrate your issue.