OL Learn

Absolute Position Subtotals of a Dynamic Table

I have a preprinted form for a dynamic table which can have from 1 to 12 lines. Is there a way to absolute position the subtotals, regardless of the number of lines? (It has to be positioned in line 13, even if the record has just one line).

Or if this is not possible, is there a way to calculate a sum field of all the detail of every record?

thank you!

Hi @akispapa,

The easiest way will be to create the complete table with 13 rows in Design mode. Make sure that the table (not a Dynamic Table) does have a unique id. View the new created table in Source mode and add a class to the first 13th table row, for example “total”. After you’ve done that please create a Control Script like the following:

Name: Example
Selector: #table-example tbody tr

results.each(function (index) {
	if (results[index].attr("class") === null || results[index].attr("class").indexOf("total") < 0) {
		// Execute JavaScript code to create the content of the detail table tr-elements...
	} else {
		// Execute JavaScript code to create the content of the ".total" tr-element...

Please note that you still have to check if the detail table does contain enough records to fill the 12 table rows with content. But for that you can use a if-statement like the following one for example:

if (record.tables["detailTableName"].length < index) {
	// Execute JavaScript code...

Hi @Marten,

Actually it did work with just a simple class added to the totals of a dynamic table:
td.totals {
line-height: 4.8mm ;
position: fixed ;
top: 190.5mm ;
font-weight: bold ;
font-size: 11pt ;

In the beginning I also had a 'right: 65mm’ property, and while the totals displayed correctly in preview, it wouldn’t print in PDF! Probably printing positioned it outside the paper.

Many thanks for your response!