Hi Michel,
In SfDataGrid, when a column is sorted, the change is notified through the SortColumnsChanged event. However, the view is not refreshed at the moment this event is triggered. As a result, Grid.View.Records is not updated when the event occurs.
To meet your requirement of accessing the records in the order displayed after sorting, you need to defer your logic until the view update is completed. This can be achieved by using Grid.BeginInvoke, which ensures that your code executes after the grid view has been fully refreshed.
Code snippet related to BeginInvoke:
Private void OnGridSortColumnsChanged(object sender, SortColumnsChangedEventArgs e) { Grid.BeginInvoke(new Action(() => { var records = Grid.View.Records; // Records are in the displayed order })); } |
Please let us know if you need any further assistance.
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Regards,
Poorani Tamilvasan