Access cell value in rowCallback
Access cell value in rowCallback

Hello,
I would like to ask a question about my code..The data that I show to my table is like:
data: [
{
"shiftDate":"2020-10-30",
"weights":{
"3":8.6,
"4":8.8,
}
}
and I define my columns :
columns: [
{"data": "shiftDate"},
{"data": "weights.3"},
{"data": "weights.4"}
]
And the table is visible and constructed fine!
Now, I want inside rowCallback: function (row, data) {
to check the value of the column weights.3
. So I write:
var weight= data.weights.3
I get an error Uncaught SyntaxError: Unexpected number
However the
var shiftDate= data.shiftDate
returns 2020-10-30
.
So how can I get this cell value?
Thank you a lot!
This question has an accepted answers - jump to answer
Answers
rowCallback: function (row, data) {
Try using the browser's debugger or
console.log( data );
to see what the structure of thedata
parameter is. Maybe you need to use something likevar weight= data.weights[3]
. I'm not sure without putting it into code. Maybe you can build a simple test case if you still need help.https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Thank you!!
The command
var weight= data.weights[3]
worked !