EhLibSupport wrote:
Hello
And how should the calculated fields be copied to the new DataSet ?
After all, the algorithm for calculating the calculated fields is stored in the original DataSet, in the OnCalcFields event handler.
of course, the value of the field is calculated in OnCalcFields event ; but the field itself is created previously in onCreate event ();
TDatasetDrivereh can't retrieve calculated fields and lookup fields. (persistent fields)
New_Persistent_FieldsUpdate : to solve this problem; fields are manually created with same names in OnbuildDataStruct event.
the good thing is that data are loaded automatically to memtableeh fields.
Code:
procedure TForm1.ddMemTableEh1BuildDataStruct(DataDriver: TDataDriverEh;
DataStruct: TMTDataStructEh);
var FIELD1 : TMTStringDataFieldEh;
FIELD2 : TMTNumericDataFieldEh;
begin
DataDriver.DefaultBuildDataStruct(DataStruct);
FIELD1 := TMTStringDataFieldEh(DataStruct.CreateField(TMTStringDataFieldEh));
FIELD1.FieldName := 'OBS' ;
FIELD1.Size := 200;
FIELD2 := TMTNumericDataFieldEh(DataStruct.CreateField(TMTNumericDataFieldEh));
FIELD2.FieldName := 'MONT_PPA_01' ;
FIELD2.NumericDataType := fdtFloatEh;
FIELD2.DisplayWidth := 10;
FIELD2.Precision := 15;
FIELD2.DisplayFormat := '#,#0.00';
end;