Is it possible to select the topmost row of the TTMSFNCDataGrid after sorting when the Grid has an TTMSFNCDataGridDatabaseAdapter. As of now it´s always staying at the selected Row.
I´ve tried changing the selection in the OnAfterSortColumn-Event but can´t fin a way to achieve this. (The TTMSFNCDataGrid.SelectCell does unfortunately not select the sorted index. It always selects the same cell reagrdless of the sorting).
Right now, it selects and synchronizes with the active record, so if your active record is 1 and after sorting the active record jumps to 50, the grid will jump to the corresponding row. If you don't want this, you could reset the active record by calling
procedure TForm1.TMSFNCDataGrid1AfterSortColumn(Sender: TObject;
AColumn: Integer);
begin
ClientDataSet1.RecNo := 1;
end;
Which will jump to the first record in the dataset and this should correspond with the first row in the grid.
I've tested this here, but in all cases, the TopRow is correct. The sorting doesn't apply because there is no content in the memo field, so the sort operation doesn't work. TopRow only changes the scroll position, and if that affects the selected row, then it will also synchronize the selected row.
Thanks for the video. We have different behavior here, but this could be due to some underlying changes we did in the database adapter related to sorting & filtering. Next version should have this fixed and is planned for next week.
Ok wait, I might be confused by the selected row, the TopRow property is not automatically selecting the top-most row. It's use to navigate in the grid. If you want this, you need to use this code instead: