Skip to content

Adding Totals on Local Array

Since local array loads so fast that we need to add a timeout for the total formula to wait for DOM to finish loading.

Add the following first
$dg->set_grid_property(array("footerrow"=>true));

Then use a separate javascript block in a timeout. 

<script>
setTimeout(function(){
    var colSum = $('#data1').jqGrid('getCol', 'quantity', false, 'sum'); // other options are: avg, count
    $('#data1').jqGrid('footerData', 'set', { 'name': 'Total', 'quantity': colSum });
}, 300);
</script>
  
You may need to change the column name and grid name accordingly.

Feedback and Knowledge Base