Data.DB.TField OnGetText
Here is a small sample of code I use. This is not code form our commercial app but a sample of working code.
I assign the OnGetText of many fields from queries to a procedure to handle the formatting of the data from those fields.
Here is a sampleof the code.
queryDatasource.DataSet:= query;
query.FieldByName('myfield').OnGetText:= OnGetFieldText;
procedure TMyForm.OnGetFieldText(Sender:TField; var Text:String; DisplayText:Boolean);
begin
Text:= Sender.AsString;
Text:= 'My Extra Text '+Text;
end;
If I attach the TDataSource queryDatasource to a datagrid.Datasource the procedure OnGetText is called. If I assign the TDataSource queryDatasource to the TfrxDBDataset.Datasource for my report OnGetText event is never called and the data from the field is presented to the report straight from the database.
Attached is a picture showing the report without the extra data from the OnGetText and a grid with the extra data as expected.
I assign the OnGetText of many fields from queries to a procedure to handle the formatting of the data from those fields.
Here is a sampleof the code.
queryDatasource.DataSet:= query;
query.FieldByName('myfield').OnGetText:= OnGetFieldText;
procedure TMyForm.OnGetFieldText(Sender:TField; var Text:String; DisplayText:Boolean);
begin
Text:= Sender.AsString;
Text:= 'My Extra Text '+Text;
end;
If I attach the TDataSource queryDatasource to a datagrid.Datasource the procedure OnGetText is called. If I assign the TDataSource queryDatasource to the TfrxDBDataset.Datasource for my report OnGetText event is never called and the data from the field is presented to the report straight from the database.
Attached is a picture showing the report without the extra data from the OnGetText and a grid with the extra data as expected.
Comments