Page 1 of 1

Reopen Query and bring to old Order

Posted: Thu 15 Jun 2017 12:28
by ralle1
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?

Re: Reopen Query and bring to old Order

Posted: Thu 15 Jun 2017 14:49
by ViktorV
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;