Sum of column

QuestionsSum of column
taha asked 9 years ago

i want to get the sum of certain filtered column

12 Answers
Abu Ghufran answered 9 years ago

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.

rethray answered 9 years ago

Do You think You will be add functionality like that in future release??
(sum or count records display on the very bottom grid)

Abu Ghufran answered 9 years ago

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.

Abu Ghufran answered 9 years ago

Hi,

John, i've emailed you the working example for reference.

Regards,

John P Gasvik answered 8 years ago

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!

John P Gasvik answered 8 years ago

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

Felix Lugaru answered 8 years ago

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.

Abu Ghufran answered 8 years ago

Hello Felix, I've emailed you.
Will be including it in upcoming build.

Thanks

jose manuel cuin answered 8 years ago

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!

Abu Ghufran answered 8 years ago

Hello Jose,

Sent you a solution via email.

Thanks

Stephen Hartigan answered 8 years ago

Hi Abu,

I need this also, can you mail me the solution?

Thanks.

Abu Ghufran answered 8 years ago

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.

Your Answer

20 + 1 =

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?