2

I am using angular/ng-table to plot numerical data in tabular form. I am not able to figure out how to bring in a row at the end of my table which shows sum of all the values of each column. I can compute the data on the server side and present it in the UI. But is there a way to achieve this in ng-table/ng-grid? Any help will be appreciated.

thanks

2
  • What of summing in the controller using the data retrieved from the server? Commented Oct 3, 2013 at 17:02
  • you can access your data array. You just need to do it in JS in the controller and show it in the template. Commented Oct 3, 2013 at 19:22

1 Answer 1

4

You mean something like this?

<table ng:init="stuff={items:[{description:'gadget', cost:99},{description:'thing', cost:101} ]}">
<tr>
    <th>Description</th>
    <th>Cost</th>
</tr>
<tr ng:repeat="item in stuff.items">

    <td>{{item.description}}</td>
    <td>{{item.cost}}</td>
</tr>
<tr>
    <td></td>
    <td>{{stuff.items.$sum('cost')}}</td>
</tr>

Sign up to request clarification or add additional context in comments.

2 Comments

@ErichBSchulz this is an Angular function, deprecated after code.angularjs.org/0.9.9/angular-0.9.9.min.js
ah thanks - that is why I couldn't find it! maybe worth updating the anser to save others wasting time?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.