Sort problem on rDBGrid

20 views
Skip to first unread message

Alejandro AG

unread,
May 9, 2025, 9:06:53 AMMay 9
to Rosi Delphi Components
After set fields on rDBGrid
SortField=Name, ID
SortDesc=0
SortDirections=A,A

How i must force to execute the new order? 
refresh? Close? Open? the is some way preferred or designed to do it?

Thks

Tomas Rosinsky

unread,
May 12, 2025, 3:47:26 PMMay 12
to Rosi Delphi Components
Hi, 
setting of sort field property directly just update sorting marks. 
If you want to update sorting of dataset then use one of following procedures. It set sorting for dataset and then update sort properties.

    { manually resort grid - calls Sorter.DoSort procedure or OnChangeSortEx or OnChangeSort event }
    function ReSort: boolean;
    { set new sort properties and call Sorter DoSort procedure or OnChangeSort procedure,
      obsolete, use ChangeSortEx for multifield sorting }
    function ChangeSort(const NewSortFieldName: string; NewSortDesc: boolean): boolean;
    { set new sort properties and call Sorter DoSort procedure or OnChangeSortEx procedure }
    function ChangeSortEx(const NewSortFieldNames, NewSortDirections: string): boolean;

Also following could be useful for you:
    { returns position of FieldName in SortFieldName (0=not found) }
    function PosInSortField(const FieldName: string): integer;
    { returns sort direction for field (true=DESC, false=ASC) }
    function GetSortDirection(const FieldName: string): boolean;
    { returns array of sort fields }
    function SortFieldNamesArr: TSortFieldNames;
    { returns array of sort directions }
    function SortDirectionsArr: TSortDirections;


I hope it helps
TomaS
Dne pátek 9. května 2025 v 15:06:53 UTC+2 uživatel aag.co...@gmail.com napsal:

Alejandro AG

unread,
May 13, 2025, 4:36:27 AMMay 13
to Rosi Delphi Components
The origin of this question is my procedure to save/load rDBGrid view, i store all view, included sort, but on load properties it load sort data (SortField, SortDesc and SortDirections) but don't execute the sort automatic (even arrows on title grid appear, but not sorted)
may be i must call or set some other property to do it automatic

For now I'm calling Sort as you say

Tomas Rosinsky

unread,
May 13, 2025, 2:21:04 PMMay 13
to Rosi Delphi Components
You can also use my PropSave components to store all DBGrids status as well as other components status to INI file or any other file.

Tomas

Dne úterý 13. května 2025 v 10:36:27 UTC+2 uživatel aag.co...@gmail.com napsal:

Alejandro AG

unread,
May 15, 2025, 3:20:57 AMMay 15
to Rosi Delphi Components
I did, but on load they take the values but not execute the sort (or may me interfere with some events i create, i must check better)
Reply all
Reply to author
Forward
0 new messages