Home - Forums-.NET - FlyTreeView (ASP.NET) - Repopulate Node after clearChildNodes()?

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Repopulate Node after clearChildNodes()?
Link Posted: 18-Jul-2007 03:13
Hi,
I use FTV in a scenario where children may change. So, I need to call clearChildNodes() from javascript and like to populate the children again, as if the node was clicked to expand. How do I do this?
BR,
Ralph
Link Posted: 18-Jul-2007 05:54
I think something like this would help:

var ignoreEvents = false;
function nodeEventHandler(treeview, node, eventType)
{
    if (ignoreEvents) return;
    ignoreEvents = true;
    if (eventType == \"collapsed\") {
        node.clearChildNodes();
        node.setPopulateNodesOnDemand(true);
    }
    ignoreEvents = false;
}


Do not forget to set:
Link Posted: 19-Jul-2007 02:32
Thanks, if the user should click again this works. What I do is somewhat different: The user has opened a node (clicked the plus-sign), removes and/or adds some children (dependent on a business rule) and wants to see the result of this action. So, what I do is call my js, this calls a webservice to do the add/remove server side - so, everything is done except showing the currently valid content of the node that is open already. I would like to start this update from the js, not by a user interaction. So, the idea was to remove the children and call directly whatever happens if a user clicks on a node to see its children - the tree would raise the populate on demand event, this would be handled server-side and everything is fine without additional clicks.
Best Regards, rawaho
Link Posted: 19-Jul-2007 06:22
So you can do

node.collapse();
node.clearChildNodes();
node.setPopulateNodesOnDemand(true);
node.expand();

This should reload nodes without user interaction.
Link Posted: 23-Jul-2007 21:39
Thank you very much, that's it.