Adding a footer to a subgrid

QuestionsAdding a footer to a subgrid
Stephen Hartigan asked 11 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,

Stephen

6 Answers
Abu Ghufran answered 11 years ago

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>

Raina answered 10 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 10 years ago

Hello,

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

David answered 9 years ago

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>

Abu Ghufran answered 9 years ago

Thanks for sharing.

Abu Ghufran answered 9 years ago
Your Answer

2 + 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 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

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

Let us improve this post!

Tell us how we can improve this post?