ArtiGrid
v1.9

Summary Bar

The Summary Bar adds an aggregate row to your grid, automatically computing values across the visible records.

Pass an array to summary() mapping each column to the operations you want: sum, avg, min, max, or count. A single column can display several operations at once.

The second argument controls formatting and layout: label and pageLabel name the total rows, decimals, thousands, and decimalSep format the numbers, and position places the summary at the top or bottom of the table.


<?php
$grid = new ArtiGrid();
$grid->table('products')
     ->crudCol([
        'id',
        'productCode',
        'quantityInStock',
        'MSRP'
     ])
     ->summary([
        'quantityInStock' => ['sum', 'avg', 'max'],
        'MSRP'  => ['sum', 'min'],
    ], [
        'label'     => 'Grand Total',
        'pageLabel' => 'This page',
        'decimals'  => 2,
        'thousands' => '.',
        'decimalSep'=> ',',
        'position'  => 'bottom', // bottom or top
    ]);

echo $grid->render();
?>
id productCode quantityInStock MSRP Actions