By: Eduardo Ponce de Leon
2020-05-23


KAS Documentation / KAS Documentation /

How to add Total Sums from columns in Table Views

By: Eduardo Ponce de Leon
2020-05-23

How to add Total Sums from columns in Table Views
How to add the numeric values of an entire column in a table view and show the sum using $viewtotals

In all the table views we have the option of displaying the sum of a column on the top of a table

 

 

This sum is only for the visible results, which means that if we are using pagination and there is more than one page, the sum is only for the current page.

For this we have one multidimensional array $viewtotals with name, col, and prefix, for example:

 

$viewtotals[0]['name'] = 'Subtotal';
$viewtotals[1]['name'] = 'Tax 1';
$viewtotals[2]['name'] = 'Tax 2';
$viewtotals[3]['name'] = 'Final Total';


$viewtotals[0]['col'] = 'subtotal';
$viewtotals[1]['col'] = 'tax2';
$viewtotals[2]['col'] = 'tax';
$viewtotals[3]['col'] = 'total';


$viewtotals[0]['prefix'] = '$';
$viewtotals[1]['prefix'] = '$';
$viewtotals[2]['prefix'] = '$';
$viewtotals[3]['prefix'] = '$';

 

in col we put the name of the column of the database. The rest is just formatting

Comments