Sort automatically upon changes in itemsource

1 Answer 25 Views
GridView
Lim
Top achievements
Rank 1
Iron
Lim asked on 07 Mar 2025, 07:47 AM | edited on 07 Mar 2025, 07:51 AM

Hi,

I have a radgridview which I have configured to sort using "telerik.RadGridView.SortDescriptors" based on whether a checkbox is tick or untick. However, upon ticking/unticking the checkbox, the radgridview does not sort based on the condition that I have specified. May I ask for the solution for this?

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 11 Mar 2025, 03:25 PM

Hello Lim,

If by changes in the ItemsSource you mean a property change in the row's data item, then this is not supported. There is a feature request for this. You can get the desired behavior by manually calling the Reset method of the SortDescriptors collection of RadGridView after the data item's property gets changed. For example:

dataItem.MyProperty = newValue;
this.gridView.SortDescriptors.Reset();

Regards,
Martin Ivanov
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Lim
Top achievements
Rank 1
Iron
commented on 13 Mar 2025, 03:20 AM

Hi Martin, I am using MVVM. In that case, would it be possible to call the reset() in ViewModel instead of codebehind?
Martin Ivanov
Telerik team
commented on 13 Mar 2025, 07:13 AM

There is no strictly MVVM mechanism for this. If you want to call this code in your view model, you can pass the SortDescriptors collection to the view model.

var viewModel = new MyViewModel() { SortDescriptors = this.gridView.SortDescriptors };

 

// in the MyViewModel class
OnMyItemPropertyChanged()
{
     this.SortDescriptors.Reset();
}

Tags
GridView
Asked by
Lim
Top achievements
Rank 1
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or