Home - Forums-.NET - FlyTreeView (ASP.NET) - Reload a node from javascript

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

Reload a node from javascript
Link Posted: 24-May-2009 22:44
Hi,

how can I reload a node in my tree from javascript?

A node is expanded, no sub nodes were loaded.
Through a web service we add a node to the tree, ie the database.
If the web service call was successful, we try to reload the selected node with the code below.
It works, almost. First item we add, nothing happens. Second item the node expands.

We use version 4.3.5.74
Any help is appreciated!


function _onMethodComplete(result, eventArgs)
{        
    if(result)
    {
        var selectedNode = treeview.getSelectedNode();
        if (selectedNode)
        {
            var expanded = selectedNode.getExpanded();
            var nodes = selectedNode.getChildNodes();
            selectedNode.collapse();
            
            for ( var i in nodes )
            {
                nodes[i].remove();
            }
            
            selectedNode.setPopulateNodesOnDemand(true);
            
            if(expanded)
            {
                selectedNode.expand();
            }
        }                
        else
        {
            alert("There is no selected node.");
        }                          
    }
    else
    {
        alert("The status couldn't be saved");
    }
}
Link Posted: 24-May-2009 23:02
[quote="jr_ewing"]
It works, almost. First item we add, nothing happens. Second item the node expands.

Your code looks good, but what is "item" and what node expands?
Link Posted: 24-May-2009 23:14
Hi,

thanks for your reply.

"Item" is a new sub node added to selected node.

When setting selectedNode.setPopulateNodesOnDemand(true) and then calling selectedNode.expand() in the javascript I expect the selected node to expand and my newly added sub node to be visible, or in other terms: the OnPopulateNodes event to be raised so that the tree gets populated. This doesn't happen when the first sub node is added, but it happens when the second sub node is added.
Link Posted: 24-May-2009 23:25
So how do you add subnodes?
Or does the code work when you return two nodes (from PopulateNode) and doesn't work when adding single one?

Also, do you have a simple test page for us to reproduce and debug your issue?
Link Posted: 25-May-2009 19:48
I wasn't able to reproduce my issue in a test page, I guess my problem is related to something else in my application. Thanks anyway!