Custom tree which can render more then 1 level in custom section
Hi,
Is there a way where we can render more then 1 level of tree in custom section.
actually, i am able to do the creation of 1 level and retrieve node underneath it.
i am tying to add one more level and add node under it .if i am doing so, it
it adding the fetched nodes in all the levels.
I am trying to add fetched data from DB under respective nodes however the below code is adding it in all the levels instead of giving the id other then -1 :(
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
System.Diagnostics.Debugger.Launch();
var nodes = new TreeNodeCollection();
var ctrl = new StatusApiController();//calling API controller
//check if we're rendering the root node's children
if (id == Constants.System.Root.ToInvariantString())
{
//creating node1 and node2
var node1 = CreateTreeNode("1", "-1", queryStrings, "Node1", "icon-smiley", true);
var node2= CreateTreeNode("2", "-1", queryStrings, "Node2", "icon-smiley", true);
nodes.Add(node1);
nodes.Add(node2);
// return nodes;
}
//checking child nodes under Node1
foreach (var addnode1 in ctrl.GetAll())
{
var node = CreateTreeNode(
addnode1.Id.ToString(),
"1",
queryStrings,
addnode1.Title.ToString(),
"icon-document",
false);
nodes.Add(node);
}
//checking child nodes under Node2
foreach (var addnode2 in ctrl.GetAll2())
{
var node = CreateTreeNode(
addnode2.Id.ToString(),
"2",
queryStrings,
addnode2.Title.ToString(),
"icon-document",
false);
nodes.Add(node);
}
return nodes; }
i tried, It not working .same results.
Is there a way ,where we can add directly to parent nodes instead of adding them in treenodecollection object.
like
Custom tree which can render more then 1 level in custom section
Hi,
Is there a way where we can render more then 1 level of tree in custom section. actually, i am able to do the creation of 1 level and retrieve node underneath it. i am tying to add one more level and add node under it .if i am doing so, it it adding the fetched nodes in all the levels.
thanks, harshit
Comment author was deleted
Yup you can :) for an example check out this code https://github.com/TimGeyssens/UIOMatic/blob/master/src/UIOMatic/Trees/UIOMaticTreeController.cs
Key is to check the id (if it's -1 then it's the first level, if it's an other id then it's an upper level)
Hi Tim,
Thanks a lot :)
I am trying to add fetched data from DB under respective nodes however the below code is adding it in all the levels instead of giving the id other then -1 :(
Thanks, Harshit
Comment author was deleted
Think you need an else before your 2 foreach statements
i tried, It not working .same results. Is there a way ,where we can add directly to parent nodes instead of adding them in treenodecollection object. like
nodes.add(node) replaced by
node1.add(node)
Thanks, harshit
Thanks Tim :) Got a way to do it.
Cheers, harshit
is working on a reply...