Have this WebDataTree:
<ig:WebDataTree ID="itemtree" class="ItemTree" runat="server" DataSourceID="hdsItem" SelectionType="Single" NodeIndent="10" InitialDataBindDepth="1"> <AutoPostBackFlags SelectionChanged="On" /> <DataBindings> <ig:DataTreeNodeBinding DataMember="dsItemCategoryRoot_DefaultView" KeyField="CategoryID" TextField="Description" ValueField="CategoryID" TargetField="Category" /> <ig:DataTreeNodeBinding DataMember="dsItemCategory_DefaultView" KeyField="CategoryID" TextField="Description" ValueField="CategoryID" TargetField="Category" /> <ig:DataTreeNodeBinding DataMember="dsItem_DefaultView" KeyField="InventoryID" TextField="Name" ValueField="InventoryID" TargetField="Inventory" /> </DataBindings> </ig:WebDataTree>...that is bound to a datasource and setup to automatically download nodes on demand, with a InitialBindDepth of 1.It works perfectly, it loads all the root nodes and then loads a set of children when I expand a node.
I also have some code that seeks a certain node in the tree. (code below) It finds the node by key, then sets that as the active node, expands it, and expands all ancestors to that point. The problem is, while it allows me to set that as the active node, the children of that node might not be loaded yet. Is there a way I can continue to have it load on demand, but also manually force it to load the children of a certain node if I need to?
itemtree.ActiveNode = MyNodeitemtree.ActiveNode.Expanded = Trueitemtree.ActiveNode.ExpandAnscestors()itemtree.ActiveNode.Selected = True
Hello kchitw,
Please let me know if you have any other questions.
Hi kchitw,
I tested the code as I posted it and it worked, but if it is not working on your side, you could try to set some timeout before expanding the second level. There is a NodePopulated/NodePopulating client-side events fired after/before a node fetch its child nodes from the server.
Let me know if this helps.
Ok, that make sense.
The way I am determining which node I want to be active is by looping through the nodes on the server, during a partial post back, until I find a match.
itemtree_Initialize won't work for me in this case, since the tree already exists and has been rendered.
I will need to have an event fire when a partial post back completes (I believe the update panel can handle that)
So once I determine what node I want to make active, I guess I would record the path/indexes to that node and record them in a hidden field or something, then after the post back completes I would read that hidden field, loop through and expand the indexes and once I get to the last index, make it the active field.
Also, for this code:
sender.getNodes().getNode(0).set_expanded(true);
sender.getNodes().getNode(0).get_childNode(0).set_expanded(true);
Would the second line need to run on a delay like the setActiveNode() does?Does sender.getNodes().getNode(0).get_childNode(0) exist at that point, or do I need to wait until it is expanded?
Is there a client-side event that fires after the next level of nodes get downloaded? That might be the best place to do this..After that event fires I can either expand the next node, or make the next node when I get to that point.
In order to be able to set active node from 3rd level of the tree, which is not initially loaded, you will have to expand all its parents first. This could be done for example in the Initialize client-side event, using code, similar to the following:
var tree;
function itemtree_Initialize(sender, eventArgs) {
tree = sender;
setTimeout("setActiveNode()", 200);
}
function setActiveNode() {
var node = tree.getNodes().getNode(0).get_childNode(0).get_childNode(0);
tree.set_activeNode(node);
If you have any questions, please let me know.
In case my request didn't make any sense, here's an example of what I am looking for. Hopefully it is more clear.
I have a tree that looks like this:
.A. A1. A1a. A1b. A1c. A2. A3.B. B1. B2.C.D
The tree is set with InitialDataBindDepth="1" so that only the first level of nodes, A, B, C, D are initially loaded.
What if when the page loads, I want to jump directly to node A1a. I want to make it be the active node, and to have the child nodes of it and all of its ancestors be loaded. Therefore you would see A, B, C, D, A1, A2, A3, and A1a, A1b, A1c