Adding a Total Row to Footer In ng-grid

Phil Sandler picture Phil Sandler · Oct 17, 2013 · Viewed 12.2k times · Source

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?

Answer

Davin Tryon picture Davin Tryon · Oct 17, 2013

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.