Hello
I am using the TrDBGridSorter and a TrDBToolBar for filtering in Zeos flavor for production, and FireDac for test in a supported configuration.
The code switches the SQL query behind a TrDBGrid, and without sorting, it works as expected.
18.2 (Zeos)
But with sorting, it throws an exception if the new query does not have a field named as the sorting field.
Workaround:
with rDGTableEditor do
begin
SortFieldName := '';
ChangeSort('', false);
end;
Filtering correctly clears itself on closing the dataset, but sorting does not.
18.3 (FireDac)
Both sorting and filtering throws an exception
Workaround not working, I always get an exception, then clears the sort
Without workaround it never ceases to throw exceptions, plus on 2+ runs adds a single _ (underscore) to the sorted field so it is even worse.
The last thing I have tried was:
procedure TForm1.SetDataSet(ASql: string);
begin
(* Workaround *)
with rDBGrid1 do
begin
SortFieldName := '';
ChangeSort('', false);
DataSource := nil;
end;
(* /Workaround *)
with FDQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from ' + ASql);
Open;
end;
(* Workaround *)
with rDBGrid1 do
begin
DataSource := DataSource1;
end;
end;
Calling:
procedure TForm1.BQuery1Click(Sender: TObject);
begin
SetDataSet('l_afabevallas');
end;
procedure TForm1.BQuery2Click(Sender: TObject);
begin
SetDataSet('szamlatipus');
end;
Exception:
:00007FF82905A80A RaiseException
@InternalRaiseAtExcept(??,??,??)
@RaiseAtExcept(??,??)
FDException($000001f05f153b70,$000001f05f1a0540,false)
FDException($000001f05f153b70,{[0]='DatS'},2,{[0]={{_Reserved1=2131899201056,VType=17}}})
TFDDatSNamedList.ErrorNameNotFound(??,??)
TFDDatSNamedList.ItemByName(??,??)
TFDDatSBindedList.ItemByName(??,??)
TFDDatSColumnList.ColumnByName(??,??)
TFDDatSColumnSublist.Fill($000001f062102aa0,$000001f05f171210,'NEV',$000001f0621035e0,$000001f062103550)
TFDDatSMechSort.DoActiveChanged($000001f05f171210)
TFDDatSMechBase.CheckActiveChanged($000001f05f171210)
TFDDatSView.CheckActiveChanged($000001f05f17c010)
TFDDatSView.SetActive(??,??)
TFDDataSet.BuildViewForIndex($000001f05f0706c0,$000001f05f13ffd0)
TFDIndex.CreateView($000001f05f13ffd0)
DeleteCreateView
TFDIndex.IndexChanged($000001f05f13ffd0)
TFDIndexes.Build($000001f062113dc0)
TFDDataSet.OpenIndexes($000001f05f0706c0)
TFDDataSet.InternalOpen($000001f05f0706c0)
TDataSet.DoInternalOpen($000001f05f0706c0)
TDataSet.OpenCursor(??,??)
TFDDataSet.OpenCursor($000001f05f0706c0,false)
TFDRdbmsDataSet.OpenCursor($000001f05f0706c0,false)
TDataSet.SetActive($000001f05f0706c0,true)
TFDDataSet.SetActive(??,??)
TDataSet.Open(??)
TForm1.SetDataSet($000001f05f0d3780,'szamlatipus')
How to properly clear filtering and sorting when reusing the dataset with different SQLs?
Best regards,
Peter