Reopen Query and bring to old Order

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ralle1
Posts: 43
Joined: Thu 27 May 2010 15:01

Reopen Query and bring to old Order

Post by ralle1 » Thu 15 Jun 2017 12:28

I want to reload a Query by doing close and open.
After this, I want to restore the last sorting.

This works fine with using IndexFieldNames like this:

Code: Select all

procedure TForm14.ReloadButtonClick(Sender: TObject);
var
  SaveIndexFields : string;
begin
  SaveIndexFields := ibcquery1.IndexFieldNames;
  ibcquery1.Close;
  ibcquery1.Open;
  ibcquery1.IndexFieldNames := SaveIndexFields;
end;
The problem ist, the result is displayed in a TCRGrid. The Grid doesn't change the small triangle symbol. It still is painted at the column with is default order acording to SQL.

Do you know a way to prevent this?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Reopen Query and bring to old Order

Post by ViktorV » Thu 15 Jun 2017 14:49

At the moment, the support of the TCRGRid component is discontinued.
But, all registered users of DAC products have source code of TCRGrid located in DAC_Install_Dir\Source\, where DAC_Install_Dir is a directory where you installed DAC product.
To solve your issue you can use the following guidelines:
- change in the CRGrid.PAS file the string

Code: Select all

  St := TCustomDADataSet(DataLink.DataSet).GetOrderBy;
into

Code: Select all

   St := TCustomDADataSet(DataLink.DataSet).IndexFieldNames;
   if St = '' then
     St := TCustomDADataSet(DataLink.DataSet).GetOrderBy;

Post Reply