Sum of ListOptions_Rendered

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mpol_ch
User
Posts: 877
Location: Switzerland

Sum of ListOptions_Rendered

Post by mpol_ch »

Hi
I am using the following code to calculate sum of zbetrag from another table.
This is working gut.
But I want to have the Sum of this column in the List page like Total in Aggregate coloumn.
Is that possible? Or is there better way to do this?

function ListOptions_Rendered() {
if ($this->Id->CurrentValue <> "") {
$zahlungen = ew_ExecuteScalar("SELECT SUM(zbetrag) FROM zahlungen WHERE zrechid='".$this->Id->CurrentValue."' Group By zrechid");
$this->ListOptions->Items["zahlungen"]->Body =number_format($zahlungen, 2, '.', '');
$this->ListOptions->Items["zahlungen"]->CssStyle="text-align:right; ";
}
}

thanks
mpol_ch


mobhar
User
Posts: 11660

Post by mobhar »

Here are the clues:

  1. Define a global variable in "ListOptions_Load" server event to hold the sum of value for that new column,
  2. Inside "ListOptions_Rendered" server event, just calculate the value of each row in that column, and use that global variable to get the result,
  3. Use "Footer" property that belongs to that ListOptions Item of that column to display the final result.

Post Reply