mData / mRender for dealing with nested arrays
mData / mRender for dealing with nested arrays
maryPo
Posts: 11Questions: 4Answers: 0
hello! I'm trying to use the function as shown in this manual https://datatables.net/forums/discussion/11251/datatables-1-9-3.
Once I get the data from the Ajax request.
$.ajax({
type: "GET",
url: cr + "/task/getAllTasks.action",
dataType: "json",
success: function (data) {
var searchTable = $('#baseTasks').dataTable({
"aaData": data,
"aoColumns": [
{ "mData": data.solutions,
"mRender": "[, ].id"
}
]
})
}
});
And I got an error "Uncaught TypeError: Cannot read property 'length' of undefined" in the file jquery.dataTables.js:1239.
I tried convert data to json, but the error remains the same.
$.ajax({
type: "GET",
url: cr + "/task/getAllTasks.action",
dataType: "json",
success: function (data) {
var searchTable = $('#baseTasks').dataTable({
"aaData": data,
"aoColumns": [
{ "mData": JSON.stringify(data.solutions),
"mRender": "[, ].id"
}
]
})
}
});
So look my data in json format:
[
{"id":1,"name":"task","solutions":[{"id":1,"answer":"3","score":5},{"id":2,"answer":"2","score":4}]},
{"id":2,"name":"sample","solutions":[{"id":3,"answer":"0","score":0}]}
]
I use the DataTables-1.10.5
This discussion has been closed.
Replies
question is not actual already. It was necessary to use
instead of