Hi again,
I'm trying to add a 'Total' footer to a subgrid. I have looked at the footer-row.php example but I'm not sure where the javascript needs to go when using a subgrid.
Thanks in advance,
Stephen
Hello,
If one need to show complete table's total in footer, refer following example.
$g->select_command = "SELECT id,invdate,total,(SELECT sum(total) from invheader) AS table_total FROM invheader";
Define a column with name table_total, and in footer data, use that table_total field.
<script>
var opts = {
'loadComplete': function () {
var grid = $("#list1");
sum = grid.jqGrid('getCol', 'table_total');
grid.jqGrid('footerData','set', {total: 'Total: '+sum[0]});
},
};
</script>
I add the footer to the subgrid, It works properly when I run the file with subgrid itself. If I run the master grid page,the subgrid has a empty footer. is there any special setting for it?
Hello,
I tested the case, and it is having issue with subgrid.
I would recommend to use master-detail grid for such purpose.
Hi,
Here is a workaround to have footer working on subgrid.
//– already on your subgrid
$c_id = $_REQUEST["rowid"]; // rowid passed from master grid
//– pass event
$e["js_on_load_complete"] = "grid_onload_sub";
$g->set_events($e);
<script>
function grid_onload_sub(id)
{
var grid_id = <?php echo $c_id;?>;
var grid = $("#_list1_"+grid_id);
sum = grid.jqGrid('getCol', 'art_ttc', false, 'sum');
sum = sum.toFixed(2);
grid.jqGrid('footerData','set', {art_ttc: 'TTC: '+sum2+' €'});
}
</script>
In following demo, expand the subgrid (+) and footer will be there.
Demo: http://phpgrid.org/demo/demos/master-detail/subgrid.php
Subgrid detail code: http://phpgrid.org/demo/demos/master-detail/subgrid_detail.phps