Row Total and Column Total calculation that gives rise to error
Row Total and Column Total calculation that gives rise to error
Please click the link below to get a feel for what I was trying to do:
http://58.64.211.82/Ed/examples/advanced/linkTable4.html
If you have just clicked the link and if it does load properly (in case it doesn't please feedback and let me know), you would have immediately got what I was trying to do.
The right-most column (column 9) is a computed column showing price * qty, and the "Total" field at the right-most of the footer is obviously meant to be the sum of all the values in column 9, which clearly doesn't work due to the error box that pops up on page load.
The obvious question is: what is the cause of the error box that pops up on page load and how to get around that?
The strange thing is that the page does load and work properly, except for the grand total at the footer of course, without any error message after I commented out the footerCallback part of the Datatable initialization, as testified by the link below:
http://58.64.211.82/Ed/examples/advanced/linkTable5.html
Please could you let me know what I need to do to fix linkTable4.html so that I can get that grand total at the footer?
Thank you in advance for your response.
This question has an accepted answers - jump to answer
Answers
There is no
computed_total
in your data source object for the rows which is why you are getting that error. Setcolumns.data
for that column to benull
and just let it use the rendered above. Note also you can't definecolumns.render
twice - only once!However, that isn't the issue that you describe above - the issue there is:
You are trying to get the data from column index 9, which as the code stands points to the existent property
computed_total
. Even if you make the above changecolumn().data()
is not the correct one to use since it doesn't have the data you want in the original source object.You need to use the
cells().render()
method to get the rendered data. For example:Allan
Hi Alan, truly grateful for your expert advice. As always, your solution works perfectly.