We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Three Grid View

Hello,
Is there a posibity to attach a new node to an existing treeview without recursive walking throught the tree.
I have a unique id fo each row.
For example i nedd to and a new item to Chilfd nodes collection of node with id 99
Can i do this without recursive walking the tree?
Thanks

1 Reply

SV Srinivasan Vasu Syncfusion Team April 20, 2016 01:33 AM UTC

Hi Lukasz,

Thanks for contacting Syncfusion Support.

We have analyzed your query and we are prepared a sample as per your requirement.  In this sample, we have a unique ID for each parent node and you can add a new item to child node collection by searching the ID parent node using GridTreeControl.InternalGrid.Nodes collection. It is not possible to find the parent node without any recursive methods or loops.

Please refer the below code sample

C#

private void Button_Click(object sender, RoutedEventArgs e)

        {           

            var viewModel = this.treeGrid.DataContext as ViewModel;


                var node = new PersonInfo() { Id = 0, LastName = "Buchanan", FirstName = "Pradap", Designation = "Employee", DOB = new DateTime() };

            

                foreach (var item in this.treeGrid.InternalGrid.Nodes)

                {

                if (item.ParentNode == null)

                {                   

                    if ((item.Item as PersonInfo).Id == node.Id)

                        {

                            // Node added

                            item.ChildNodes.Add(new GridTreeNode(item.Level+1, node, false, item));

                        }

                   }                   

                }

                treeGrid.InternalGrid.ReloadNodes();           
        }       


Please find the sample from the below location,

Sample Location: http://www.syncfusion.com/downloads/support/forum/123737/ze/GridTreeControlSample-1137983568
 
Regards,
Srinivasan


Loader.
Up arrow icon