Multiply values and apply style in Datatables
Multiply values and apply style in Datatables

Dear community,
I would like to understand how to multiply column values and apply style in Datatables.
Currently my columns section looks like this :
"columns": [
{ data: "id" },
{ data: "brand" },
{ data: "description" },
{ data: "nb_ref" },
{ sortable : false, data: "cost", render: $.fn.dataTable.render.number( ' ', '.', 2, '€' ) },
]
what I would like in the 5th column is to multiply the "cost" by the "nb_ref" (the value of the 4th column) and still apply the number format.
Any idea about how to achieve ?
thanks
Adam
This question has an accepted answers - jump to answer
Answers
You would need to have a function for
columns.render
- third parameter will be the data for the entire row. You would then need to format it as a number within that function.This thread has an example of that.
Colin
This is great. Thank you Colin !