LiveBindings FMXGrid and Calculations

Hi 


I have a FMXGrid bound visually to a FDMemtable. I have 5 columns on the grid which I want to show a sum calculation however the fixed footer row shows the last record in the data set instead of the summary calculation. How do I overcome this ?




Thanks

Hi, 


You cannot add a sum calculation while maintaining an active connection, you will need to set the property TMSFMXGrid1.SaveDataSetData to true and then disconnect the dataset. Afterwards, you can add a sum calculation.

Kind Regards, 
Pieter

Thanks Pieter 


When you say disconnect the dataset do you mean FDMemtable.close ? 

My grid is bound to mtOrderLines which gets populated like this :


    LDataSet := TFDJSONDataSetsReader.GetListValueByName(DataSetList, 'OrderLines');
    datamod.mtOrderLines.Active  := False;
    datamod.mtOrderLines.AppendData(LDataSet);


Then should I do this :

  gdOrderLinesTMS.SaveDataSetData := true;
  datamod.mtOrderLines.Close;
  gdOrderLinesTMS.FixedFooterRows := 1;
  gdOrderLinesTMS.ColumnCalculation[3] := ccSUM;
  gdOrderLinesTMS.ColumnCalculation[4] := ccSUM;
  gdOrderLinesTMS.ColumnCalculation[6] := ccSUM;
  gdOrderLinesTMS.ColumnCalculation[7] := ccSUM;
  gdOrderLinesTMS.UpdateCalculations;


Hi, 


Correct, it should be the equivalent of ClientDataSet.Active := False for example.
Then you should indeed execute the code you mention.

Please note that when setting the dataset to active again you will lose the sum calculation.

Kind Regards, 
Pieter

Thanks, I will play around with this.