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

SelectedItem not highlighted when datagrid is filtered


I have a Syncfusion.UI.Xaml.Grid.SfDataGrid ( with SelectedItem="{Binding CurrentTask}" and ItemSource="{Binding Source={StaticResource TaskViewSource}}" set in XAML.

In code-behind, when something changes to the CurrentTask, I first save the ID of the CurrentTask in CurrentTaskID and save the modified task to the context. Then I reload the ItemSource (by doing TaskViewSource.Source = Context.Tasks.Local and TaskViewSource.View.Refresh() ), and reset CurrentTask to the task previously selected (CurrentTask = DataContext.Find(CurrentTaskI).First() ).

However, after doing this on a filtered DataGrid, the SelectedItem is not highlighted anymore. On the other hand, when doing this on a non-filtered DataGrid it is working fine.

What can I do to solve this?


1 Reply

GG Gowtham Gopalsamy Syncfusion Team November 20, 2019 08:51 AM

Hi Koen, 
Thank you for using Syncfusion controls. 
We have analyzed your query to highlight the selected items after resetting the datasource. You can highlight the same selected items in another new datasource and you have the same record in both datasource .Otherwise, you can use the SelectedIndex to highlight the  selectedItem another new datasource. 
Please refer the below code snippet, 
var CurrentTask = this.dataGrid.ResolveToRowIndex(index); 
this.dataGrid.SelectedIndex = CurrentTask; 
Please refer the sample in below link, 
Please refer the UG link in below, 
Please let us know, if you require further assistance on this. 

Live Chat Icon For mobile
Up arrow icon