Adding a Total Row to Footer In ng-grid
Asked Answered
O

1

5

I can't seem to find documentation on how I might accomplish this.

I'd like to add totals to the bottom of my grid, in the footer area (i.e. not a standard row that scrolls). Since I am using paging, the totals will need to come from the server--I need the total of all rows, not just displayed rows.

Is this possible?

Ostentation answered 17/10, 2013 at 20:27 Comment(0)
G
13

Yes, you should be able to do this using the footerTemplate. To enable the footer set the showFooter grid option to true. You can replace the footer template by using the grid option footerTemplate.

The footer sites at the bottom of the grid and does not scroll. Since the footer template sits outside the grid, you will have to replace the default template with your own and align the columns.

Inside your custom footer template, you can call into your controller scope, therefore, retrieving any server-side totals values.

Here is a very simple plunker: http://plnkr.co/edit/31flwE?p=preview

Hope this helps.

Goodhen answered 17/10, 2013 at 20:47 Comment(6)
Nice! They should add this example to the docs--I have to imagine it's a common requirement.Ostentation
Hmm, if I use an html file for the template, it doesn't work (it just uses the original template). Oddly, if the path is wrong to the template (which it isn't going to use anyway), it blows up. Maybe I'll grab the latest version and see if that fixes it.Ostentation
Have you tested this? What I see is the standard template if it loads successfully (I see it request and get the file), and it bombs if I have the path wrong (I get a 404 and the whole grid bombs). I will see if I can fork your plnkr and reproduce.Ostentation
Got it. Seems you can't name the html file "footerTemplate.html" or it gets confused. :)Ostentation
How do you reference the html file instead of using a string? Is the only other way to create a route to that file? Doing something like '/public/new_footer_template.html' has a no route matches error?Reifel
if i use this type of think other pagination options are not showDissidence

© 2022 - 2024 — McMap. All rights reserved.