I work with dataTables
and responds data like this:
{
"draw": "1",
"iTotalRecords": 1,
"iTotalDisplayRecords": 1,
"aaData": [
{
"id": "6",
"subject": "Hello",
"body": "please check your system immediately",
"sender_id": "2",
"reciever_id": "1",
"status": "{"1": {"is_flag": 1, "is_label": 1, "is_delete": 1, "is_archive": 1, "is_favorite": 1}, "2": {"is_flag": 1, "is_label": 1, "is_delete": 1, "is_archive": 1, "is_favorite": 1}}",
}
]
}
As you see, status
has JSON format data in MySQL
database like that:
{
"1": { // num 1
"is_flag": 1,
"is_label": 3,
"is_delete": 1,
"is_archive": 1,
"is_favorite": 0
},
"2": { // num 2
"is_flag": 1,
"is_label": 1,
"is_delete": 1,
"is_archive": 1,
"is_favorite": 1
}
}
So, I need to render status
data with dataTables
rowCallback
method with if conditional to select num
and then addClass
into row
like this:
rowCallback: function(data, type, row) {
var num = 1;
if(row.status.num.is_archive == 1){
$(row).addClass('selectRow');
}
}
In action I see this error:
Uncaught TypeError: Cannot read properties of undefined (reading ‘num’)
How do can I fix this error?!