Get the records from the datagrid in the sequence that is displayed

Hello,

I use the data displayed in the sfdatagrid in an other form. 

Grid.View.Records gives me the records in the sequence that they are displayed.

After changing the sorting in the grid. The other form also needs the be redrawn.

Grid.SortColumnsChanged event signal this changes, but Grid.View.Records isn't update yet.

How can I get notified if Grid.View.Records is updated.


Thanks,


Michel



3 Replies 1 reply marked as answer

PT Poorani Tamilvasan Syncfusion Team April 21, 2026 04:56 PM UTC

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

Marked as answer

MV Michel van Bergen April 22, 2026 10:51 AM UTC

Hi  Poorani,


This did the job.

Tanks for the fast solution.


Regards


Michel



SR Senthilkumar Ranganathan Syncfusion Team April 23, 2026 04:58 AM UTC

Michel van Bergen,
 

Glad that your requirement is fulfilled! We are closing this ticket now. Please open a new ticket if you need any assistance, we will be happy to help you.


Loader.
Up arrow icon