Sum data=null
Sum data=null
Coder102
Posts: 78Questions: 2Answers: 0
var table = $("#table").DataTable({
searching: false,
info: false,
paging: false,
ordering: false,
data: dataf,
columns: [
{
title: "a",
data: "a",
},
{
title: "b",
data: "b",
},
{
title: "c",
data: "c",
},
{
title: "d",
data: null,
render: function (data, type, row) {
return numero.d;
},
},
],
});
var sumb = table.column(1).data().sum();
var sumc= table.column(2).data().sum();
var nsp=table.column(3).data() -sumb+sumc
http://live.datatables.net/wobijesu/1/edit
Hello, I want to subtract the sum of column 1 plus column 2 from column 3 but I don't know how to do it because I can't use column (3) .data since the data is null
in short, from column 3 subtract column 1 plus column 2 and store it in the variable nsp
This discussion has been closed.
Replies
you can use
cells().render()
to get the rendered values. Maybe something like this would work:Kevin
dont work, give back a NaN
another thing. In column 3 I want to show that result, the result of number.d - (sumCorrectas + sumIncorrectas)
Sorry, Im not clear on what you are trying to achieve. Are you trying to do this on a row by row basis? Something like this example?
What is the result of this?
Can you build a running test case to show what you have so we can help with your solution?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
No, I want to do a calculation.
I want to subtract from column 3 column 1 plus column 2 and save it in a variable.
calculator= column 3 - (column 1.SUM + column 2.SUM)
and also show in column 3 that result
PSEUDOCODIGO
http://live.datatables.net/siqiweya/2/edit
I try this but not found
Pseudo code doesn't help. Can you build a running test case with an example of your data?
If you are trying to calculate with sums of columns then you either
drawCallback
if the data changes orinitComplete
to run only once if the data is static.Not sure how you can use a particular cell as part of a calculation and store that back into the same cell. I think Excel calls this reciprocal data.
Kevin
Can show you in a private message? because i use an api
Just get an example of your data and use a Javascript variable. See this example. All we need is an example of the data. We don't need to see the actual API call.
For example you have this:
Sounds like you want to use the
numero
variable as part fo the calculation. Put some values in it as part of the test case. Put some real or made up data in your other columns.Kevin
Sorry the example you PM's me has a lot of extra code for the problem we are trying to solve.
Is this what you are looking for?
http://live.datatables.net/vohasiti/1/edit
Kevin
I try this, thanks
You need to use the
data
parameter to access the row data. I'm not sure whatfilas
is. For example:Kevin