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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Deleting Rows and controlling the selected Node.

Thread ID:





123557 Mar 30,2016 05:18 PM UTC Apr 1,2016 11:21 AM UTC WPF 3
Tags: GridTreeControl
Asked On March 30, 2016 05:18 PM UTC

I have an app with a GridTreeNode that is populated via a viewmodel. The xamL used is

    <syncfusion:GridTreeControl x:Name="_tree" 
ItemsSource="{Binding FHIRModelNodes}"
        Width="490" AllowAutoSizingNodeColumn="False" 

I need to be able too delete the selected node (the GridTree is set to single row selection). I'm not sure if I am doing this correctly, the way I delete the node is directly from the viewmodel. This nearly works the problem is that as I have deleted the "selected node" the control the makes another node selected.

I need to be able to set the selected node by code. I have tried doing this by using code along the lines of :

_myGridTree.SelectedNode =_theNodeIwant;

Although this appears to work and the intended node is selected, I end up with two nodes selected (even though the control is set to single row selection). I guess I must be doing it wrong.

So a few questions.

1) How do you unselect all nodes by code
2) What is the correct way to delete a node (and have this reflected back into the viewmodel)
3) I am assuming the way to specify the node I want to be selected is as per http://www.syncfusion.com/forums/121500/setting-selected-node 


Jayapradha S [Syncfusion]
Replied On March 31, 2016 12:36 PM UTC

Hi Richard,

Thank you for contacting Syncfusion Support.

We have analyzed your queries and please find the details below,

Regarding Query: How do you unselect all nodes by code

You can deselect all the nodes by clearing the SelectedNodes as below,
Code Example:

Regarding Query: What is the correct way to delete a node (and have this reflected back into the viewmodel)

You can delete a node from treegrid and able to delete that node from view model also,
Code Example:

var viewModel = this.treeGrid.DataContext as ViewModel;


if (treeGrid.SelectedNodes.Count == 0)


var node = treeGrid.SelectedNodes[0];           

viewModel.PersonDetails.Remove(node.Item as PersonInfo);

foreach(var person in viewModel.PersonDetails)


    person.Children.Remove(node.Item as PersonInfo);


We have prepared a sample for your requirement and please find the sample from the below location,
Sample link: http://www.syncfusion.com/downloads/support/forum/123557/ze/GridTreeControl-1907522355

Regarding Query: I am assuming the way to specify the node I want to be selected is as per http://www.syncfusion.com/forums/121500/setting-selected-node 
Yes. You can select a specific node by adding a node to TreeGrid.InternalGrid.SelectedNodes as explained in the above forum.


Replied On March 31, 2016 11:29 PM UTC

Thanks for the assistance, I have just about got it working now.

I have a slight problem in that after I "deselect" the selected nodes using the code suggested:


The "row selection" is removed as desired, but there seems to be some form of "cell" selection, marked with a light blue border how do I get rid of that?
The image has the tree before delete on the right and after delete on the left.

Jayapradha S [Syncfusion]
Replied On April 1, 2016 11:21 AM UTC

Hi Richard,

You can clear the current cell border while clearing the selected nodes by using the below code example,

Code Example:




This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon