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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I de-select a row after it's selected?

Thread ID:

Created:

Updated:

Platform:

Replies:

146939 Aug 26,2019 01:27 PM UTC Sep 6,2019 06:02 AM UTC WPF 7
loading
Tags: SfDataGrid
Mark
Asked On August 26, 2019 01:27 PM UTC

I'm currently using a SFDataGrid in WPF and I was wondering how do I de-select a row after it's selected?

Is there a row selected event so I can do like a 'if old selected row == new row selected then row selected = null? 

Farjana Parveen Ayubb [Syncfusion]
Replied On August 27, 2019 11:22 AM UTC

Hi Mark, 
 
Thank you for using Syncfusion controls. 
 
We have analyzed your query, SfDataGrid supports different types of SelectionMode (Single, Multiple, Extended and None). By default, you can able to de-select the selected row in Multiple selection mode. So, could you please share which SelectionMode is you have used in your application, that will help us to provide the better solution. 
 
 
Regards, 
Farjana Parveen A  


Mark
Replied On August 27, 2019 04:08 PM UTC

My SfDataGrid's SelectionMode is Single. Thank You.

Farjana Parveen Ayubb [Syncfusion]
Replied On August 28, 2019 07:25 AM UTC

Hi Mark, 
 
Thank you for your update. 
 
We have analyzed your query, currently we don’t have a support for de select the selected row in Single SelectionMode in SfDataGrid, but you can achieve your requirement by set the SelectedItem as null in PreviewMouseUp event in SfDataGird. 
 
Please refer the below code example 
 
dataGrid.PreviewMouseUp += dataGrid_PreviewMouseUp; 
void dataGrid_PreviewMouseUp(object sender, MouseButtonEventArgs e) 
{ 
    var record = this.dataGrid.GetRecordAtRowIndex(dataGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex); 
    if (dataGrid.SelectedItems.Contains(record)) 
        dataGrid.SelectedItem = null; 
} 
 
 
We have considered to provide support for “Support to deselect a record in single selection mode” in WPF and logged feature request for the same. We will implement this feature in any of our upcoming release.  
 
At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest. We will let you know when this feature is implemented. We appreciate your patience until then. 
 
Thank you for requesting this feature and helping us define it. We are always trying to make our products better and feature requests like yours are a key part of our product growth efforts. 
 
 
Note: The provided feedback link is private and you need to login to view this feedback. 
 
If you have any more specification/suggestions to the feature request, you can add it as a comment in the portal and cast your vote to make it count. 
 
Regards, 
Farjana Parveen A 


Mark
Replied On September 5, 2019 03:50 AM UTC

Thanks but unfortunately it's not working the way I need it to, it sets the selected item to null NO MATTER WHERE I do the mouse up event instead of just working if I mouse up on top of the selected row.

Farjana Parveen Ayubb [Syncfusion]
Replied On September 5, 2019 10:03 AM UTC

Hi Mark, 
 
Sorry for the inconvenience caused. 
 
You can get the row index from PointToCellRowColumnIndex method and set the SelectedItem as null, instead of get the row index from CurrentCell. 
 
Please refer the below code example 
 
dataGrid.PreviewMouseUp += dataGrid_PreviewMouseUp; 
void dataGrid_PreviewMouseUp(object sender, MouseButtonEventArgs e) 
{ 
    var rowIndex = dataGrid.GetVisualContainer().PointToCellRowColumnIndex(e.GetPosition(dataGrid.GetVisualContainer())).RowIndex; 
    var record = this.dataGrid.GetRecordAtRowIndex(rowIndex); 
    if (dataGrid.SelectedItems.Contains(record)) 
        dataGrid.SelectedItem = null; 
} 
 
 
Please let us know if you need any further details on this. 
 
Regards, 
Farjana Parveen A 


Mark
Replied On September 5, 2019 11:06 AM UTC

Perfect! Thank you, that did the trick.

Farjana Parveen Ayubb [Syncfusion]
Replied On September 6, 2019 06:02 AM UTC

Hi Mark, 
 
Thanks for the update. 
 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Farjana Parveen A 


CONFIRMATION

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

Live Chat Icon For mobile
Live Chat Icon