Home - Forums-.NET - FlyTreeView (ASP.NET) - Populate all Nodes before DragOut

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

Populate all Nodes before DragOut
Link Posted: 13-May-2010 02:44
HI,

I am using Flytreeview control for display data from db and make operation like Drag & Drop.

I have a Two Treeview in one page.
Tree2 Populates only root nodes from Database.
when I click on Expand on root node then it's only sub child is loaded successfully.

I have a record like
root node hase 5 child node
  -- child1 node has a 15 child node
     -- child1.Child1 node has a 25 child node
  -- child2 node has a 10 child node
  -- child3 node has a 20 child node
  -- child4 node has a 25 child node
  -- child5 node has no child node

my javascript code is below to load All child Nodes in Tree

function onSelectedNodeChangedHandler(sender, oldNode, node)
{
    var from = oldNode ? oldNode.getValue() : "null";
    var to = node ? node.getValue() : "null";
}
function flyTreeView1_OnDragStart(node)
{
  expandNodes(node);
}
function expandNodes(node)
{
  var childNodes = node.getChildNodes();

  for (var i = 0; i < childNodes.length; i++)
  {
    var child = childNodes[i];
    child.expand();
  }
      for (var i = 0; i < childNodes.length; i++)
  {
        var child = childNodes[i];
            expandNodes(child);
      }
}

When i click on Root node of Tree2 which has child node describe above which is not populated,and start Drag from Tree2 to Tree1
at time of Drag flyTreeView1_OnDragStart method
is called and start populate all child/sub child node.

but in some cases when i drop node into tree1 and check it's child node then some child node is loaded successfully and some node is not loaded.

so my question is How can we check All node is successfully loaded then Drop it to Tree1 other wise wait for population nodes.
Link Posted: 14-May-2010 03:18
The problem is that node.expand() is an async function and starts loading child nodes (if they are to be loaded on demand).
So you cannot guarantee that subnodes are loaded by calling expand().
Link Posted: 14-May-2010 22:08
Thanks for Quick response

let me Explain you in detail

my all root node have a child node and all are populated on demand when user click on expand then child nodes are populated.

in my case when user start drag from one tree to another tree then i have to populate all nodes of selected dragged node before Drop.

for this i made one function expandNodes this function which perform expand all child/subchild nodes if nodes is already populated then only expand it and if node is not populated then first populate it then expand it.

Now my problem is i want to identify , All Child/Subchild nodes are populated successfully then and then that selected node will drop to the another node.

Can you please help me out how to find this.

Thanks in Advance.
Link Posted: 18-May-2010 02:10
To identify whether a node has already been populated, you can just check if node.getChildNodes().length != 0.