EhLib.Com
https://forum.ehlib.com/en/

TmemtableEh & calculated fields
https://forum.ehlib.com/en/viewtopic.php?f=5&t=1165
Page 1 of 1

Author:  souarit [ 03 Aug 2022, 10:07 ]
Post subject:  TmemtableEh & calculated fields

hello .. TMemTableEh can't load calculated fileds from source dataset ...is there any solution?

Author:  EhLibSupport [ 08 Aug 2022, 17:33 ]
Post subject:  Re: TmemtableEh & calculated fields

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.

Author:  souarit [ 09 Aug 2022, 12:13 ]
Post subject:  Re: TmemtableEh & calculated fields

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_Fields

Update : 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;

Author:  EhLibSupport [ 09 Aug 2022, 22:17 ]
Post subject:  Re: TmemtableEh & calculated fields

But the new fields will no longer be calculated. Also will not change values if the data in dependent fields changes.

Author:  souarit [ 10 Aug 2022, 12:25 ]
Post subject:  Re: TmemtableEh & calculated fields

EhLibSupport wrote:
But the new fields will no longer be calculated. Also will not change values if the data in dependent fields changes.


exact ; but now the most important thing for me is retrieving lookup fields.
and for updating data in memtableEh just do close/open.

thanks.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/