TMSFMXGrid Sorting problem

Sorting works well when I assign values in this way on form creation: TMSFMXGrid.Cells[Col,Row] := SomeValue.

1) if I set the same values to CellString in the OnGetCellData event, Sorting doesnt work any more. eg.
TMSFMXGridGetCellData(Sender: TObject; ACol, ARow: Integer; CellString: string);
  CellString := ARow.ToString();
(If it matters: if I do the same to CellString in OnCellEditGetData event, Sorting works too.)
2) if I set the same values to Cells[Col,Row] in OnGetCellData event, Sorting works, but then I will get another problem, that the grid is not actually updated correctly to show the value in each cell at the beginning (that means, on app starting I will get an "empty" grid. all cell values will become "visible" after i click a column header to sort the grid. Begin-/EndUpdate dont fix this problem.)


When using OnGetCellData, the ARow remains identical even when sorted. If you are using the grid in virtual mode, you might need to sort the data that is returned through the OnGetCellData manually. This can be done in the OnCanSortColumn event.

Kind Regards, 
thx a lot for the tip. if i want to use the 2) option in my first post, how should i update/reset the grid correctly to make everything shown immediately?

You can wrap the code with BeginUpdate and EndUpdate.

Kind Regards,