Categories > TinyButStrong general >

Adding Rows vaules......

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Ken Roberts
Date: 2005-03-06
Time: 17:36

Adding Rows vaules......

Is there a way to add up the values of the rows returned of a certain column and display the results at the bottom of the column.  For example, of you have an invoice with items that are pulled from a database, you want a sub-total and a total at the bottom.  Can this be accomplished with TBS?  I have scoured the forum and manual, but I see no mention.  Any help would be appreciated.
By: Skrol29
Date: 2005-03-06
Time: 19:26

Re: Adding Rows vaules......

Hello,

You can do it using parameter 'onformat' and a user function.
The user function will enable you to calculate sub-total and total on a extra field, or in a global variable.
By: totaller
Date: 2005-07-10
Time: 12:55

Re: Adding Rows vaules......

And then how do I display it on the bottom? Since $TBS->Show(); ends the execution of the script and the totals are calculated during $TBS->Show();
By: Skrol29
Date: 2005-07-11
Time: 01:08

Re: Adding Rows vaules......

Just store the total in a global variable like $total, then add the corresponding Var Field in the template ([var.total]).
Var Fields are merged during the Show() method.

By the way, you can prevent TBS to ends the script after the Show() method using property Render.