running totals and accessing other rows from meta
running totals and accessing other rows from meta

Hi,
I'm trying to make a running total column in a table.
A solution I came up with accesses the value of a cell in the previous row using:
meta.settings.aoData[meta.row-1].anCells[3].innerText
but this seems a little hacky, is there a better way?
code here:
http://codepen.io/jasonblewis/pen/egVPNP?editors=0010
any advice would be appreciated.
This discussion has been closed.
Answers
Jason, thanks for the workaround. I'm trying to do the same thing using
cell(meta.row-1, meta.column).data()
but the value is returned empty.
The settings object is considered to be private and thus shouldn't be accessed externally.
There are a couple of issues with using
aoData[ meta.row - 1]
:There is basically no good way to do a running total with the rendering callback.
I think a better approach would be something like the index column example - although obviously with a summation of data rather than just a counter.
Allan
Allan - can you please show more example or little bit more explain how to make with index column
Happy to create an example under the support 60 package.
Allan
This is old question, reminded me of my DataTables post, which I think turned into a GitHub pull request
It contains an example I created of a running subtotal (row groups):
http://live.datatables.net/sajaxota/6/edit
I know I had other versions that posted the full total and, but I don't have any available online. For anyone else coming to this post, maybe this will lead you in a possible direction for calculating totals