You need to perform such operations in custom sql query, using sql driven maths functions. There is no option for it right now at grid level.
Do You think You will be add functionality like that in future release??
(sum or count records display on the very bottom grid)
Hi,
It's already there. You can use it in this way.
<script>
var opts = {
'loadComplete': function () {
var grid = $("#list1"),
sum = grid.jqGrid('getCol', 'amount', false, 'sum');
grid.jqGrid('footerData','set', {amount: 'Total: '+sum});
}
};
</script>
Where list1 is identifier for grid, and amount is field to sum.
This feature is part of paid version.
I have tried the last mentioned script but can't get it showing. I have used a regular Query to count but how do I get the result in the footer (or a line at the bottom of the grid).
I can se the frase "fotterdata" in the above code. Is it possible to put my result in the bottom of the grid? (I have searched "all over").
Thanks!
I can add: the script you mention here (Ghufran): it needs to be put outside the php-hooks? It looks like it. But where do I put it in the code? If inside the php-hooks – where?
Thanks
Please send me another example of the post, it is very necessary!
I do not understand why this example is not in the demo scripts paid version.
Hi again Abu,
Is there a way to put an overall sum in the bottom of the grid?
I know there's a way to do so in the paid version. Unfortunately, I'm using the free version because we're low on budget.
Thank you!
Hello,
Solution is mentioned in Faqs.
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";
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>
Refer footer-row.php for more help.