Page 1 of 1

Grid view changes after sorting

Posted: Fri Apr 07, 2023 2:24 am
by 18692679
To recreate:
1. The user scrolls vertically (to the right) and put into view a column that was not first visible
2. Then sorts by this column

The grid scrolls back back to the left (the sort is being maintained)

I'm using: windows 10, Lazarus 2.2.4, Grid 1.1

Re: Grid view changes after sorting

Posted: Fri Apr 07, 2023 2:25 am
by 18692679
Missing is the first state of the grid:

Re: Grid view changes after sorting

Posted: Fri Apr 21, 2023 12:33 pm
by Marc
Hello,

Thank you for the issue report. We will look for a solution for it.

In the meantime there may be some form of workaround available using the current x and y scroll locations taken before the sort.

ie.

Code: Select all

  private
    { Private declarations }
    oldX : Single;
    oldY : Single;
You can obtain scroll positions:

Code: Select all

type
  MyScrollableControl=class(TScrollableControl);

procedure TMyForm.Button5Click(Sender: TObject);
begin
  oldX := MyScrollableControl(TeeGrid1).GetScrollX;
  oldY := MyScrollableControl(TeeGrid1).GetScrollY;
end;
Those can be restored via:

Code: Select all

  MyScrollableControl(TeeGrid1).SetScrollX(oldX);
  MyScrollableControl(TeeGrid1).SetScrollY(oldY);
If you are running the sort from a button then you could add the code in there; if not then we'll likely need to think of another way in.

Regards
Marc Meumann