Export Footer Row

QuestionsExport Footer Row
Gary Brett asked 10 years ago

Hello Abu, I am trying to export a grid with footer row data but it simply adds the 2 hidden columns, running total & table total and omits the actual sum at bottom, is there any way around this?

Thank you

11 Answers
Gary Brett answered 10 years ago

Also I cannot seem to get that actual totals to add up, the only one display is the grand total which I don't really need? On the demo there are 3 totals, I need the one on the left but it doesn't output in my grid?

Pastebin http://pastebin.com/pPVQdzPn

Thank you

Abu Ghufran answered 10 years ago

When you set:

grid.jqGrid('footerData','set', {tbl_invoice_data: 'Total: '+t});

The 'tbl_invoice_data' should be the exact column name $col["name"] below which you want to show data in footer.
I see that no col exist with this name. Replace it with one of the displayed col name.

Gary Brett answered 10 years ago

Hi Abu, I see that mistake shortly after I posted and changed but it still only outputs Grand Total

grid.jqGrid('footerData','set', {id: 'Total: ' + sum, total: 'Sub Total: '+sum_running, total: 'Grand Total: '+sum_table});

grid.jqGrid('footerData','set', {total: 'Total: '+t});

All I need is the total of displayed records [left on your demo] but think something is incorrect, when grid loads it shows 'Grand Total: undefined'

Gary Brett answered 10 years ago

Hi Abu, I have resolved this, the id was set as hidden which also hides the Grid Total. Am I able to move the total across to the right of the grid and remove Grand Total, I have tried everything but cannot find a way to do this.

Also is it possible to export the footer with grid into pdf, currently it exports the grid with no footer and the 2 virtual columns?

Thanks

Abu Ghufran answered 10 years ago

Change

grid.jqGrid('footerData','set', {id: 'Total: ' + sum, tbl_invoice_data: 'Sub Total: '+sum_running, total: 'Grand Total: '+sum_table});

to

grid.jqGrid('footerData','set', {total: Total: '+sum});

This means, after removing all other, show footer row under column 'total' with the value 'Total: <sum>'

Currently footer export is not supported. As an alternate, you can use custom pdf export and add footer row data manually.

Code: http://phpgrid.org/demo/demos/appearence/footer-row.phps – LIne 32,98,120
Live: http://phpgrid.org/demo/demos/appearence/footer-row.php

Gary Brett answered 10 years ago

Hi Abu, thank you, the footer export function works perfectly the total is under wrong column but I guess that maybe related to the issue below, much appreciated..

I have tried grid.jqGrid('footerData','set', {total: Total: '+sum'});

which removed footer completely & also tried

grid.jqGrid('footerData','set', {id: 'Total: ' + sum, total}); which makes grid stay on load, never actually loads though..

Thank you

Abu Ghufran answered 10 years ago

My last message had some quotes related issue. Let me explain again.

The notation in { } is { key: value }
Now key should be the column name, which is total.
And value will be 'Total' string concat (+) with JS variable sum which is (i guess) calculated earlier in function.

grid.jqGrid('footerData','set', {total: 'Total: '+sum});

Gary Brett answered 10 years ago

Hi, eventually found a way to make this work by changing code as follows, adding the false to end of line fixed it..;

// 4th arg value of false will disable the using of formatter

grid.jqGrid('footerData','set', {total: 'Total:£ '+sum}, false);

Thanks

Abu Ghufran answered 10 years ago

Thanks for sharing.

Abu Ghufran answered 10 years ago

You can format is using JS.

For e.g. if 't' is variable, then to make 2 decimal places figure set:

t = t.toFixed(2);

Gary Brett answered 10 years ago

No problem Abu, still a few little odd things, when it toitals it does not include any end zeros..

For example on grid the total column adds up to 1351.50 but displays only as 1351.5. Not sure its possible to format it?

Your Answer

19 + 11 =

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?