Adding a footer to a subgrid

QuestionsAdding a footer to a subgrid
Stephen Hartigan asked 7 years ago

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,


6 Answers
Abu Ghufran answered 7 years ago


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.

var opts = {

'loadComplete': function () {
var grid = $("#list1");
sum = grid.jqGrid('getCol', 'table_total');
grid.jqGrid('footerData','set', {total: 'Total: '+sum[0]});


Raina answered 6 years ago

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?

Abu Ghufran answered 6 years ago


I tested the case, and it is having issue with subgrid.
I would recommend to use master-detail grid for such purpose.

David answered 5 years ago


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";

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+' €'});

Abu Ghufran answered 5 years ago

Thanks for sharing.

Abu Ghufran answered 5 years ago

In following demo, expand the subgrid (+) and footer will be there.

Subgrid detail code:

Your Answer

6 + 17 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

We are sorry that this post was not useful for you!

Let us improve this post!