Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Harshit 64 posts 226 karma points
    Oct 27, 2015 @ 04:57
    Harshit
    0

    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

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 27, 2015 @ 07:56
    Tim Geyssens
    0

    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)

  • Harshit 64 posts 226 karma points
    Oct 27, 2015 @ 08:39
    Harshit
    0

    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 :(

            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; }
    

    Thanks, Harshit

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 27, 2015 @ 09:34
    Tim Geyssens
    100

    Think you need an else before your 2 foreach statements

  • Harshit 64 posts 226 karma points
    Oct 27, 2015 @ 10:19
    Harshit
    0

    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

  • Harshit 64 posts 226 karma points
    Oct 28, 2015 @ 05:11
    Harshit
    0

    Thanks Tim :) Got a way to do it.

    Cheers, harshit

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies