Nested JSON data not appear in table
Nested JSON data not appear in table
mastersuse
Posts: 61Questions: 28Answers: 0
How to print result from nested JSON like below? I have read multiple answer here but not solve.
This is what I have tried to do but No records to display
appear.
DATATABLE
$('#myTable').DataTable({
processing: true,
language: {
zeroRecords : "No matching records found",
loadingRecords : "<img src='img/icon/ani_loading_1.gif'/>",
emptyTable : "No records to display",
searchPlaceholder : 'Search...',
sSearch : '',
lengthMenu : '_MENU_ items'
},
destroy: true,
ajax: {
url: url_pw_route,
crossDomain : true,
type : "POST",
cache : false,
dataType : "json",
contentType: "application/json",
dataSrc : "pw_route.0.pw_route_xc.0",
data: function(d) {
return JSON.stringify({"action": "read", "pw_id": pw_id });
}
},
columns: [
{ data : "ne_name", "className": "text-center" }
],
});
JSON DATA
{
"result": "success",
"pw_route": [
{
"pw_route_id": "1",
"pw_id": "11",
"pw_route_xc": [
{
"pw_route_id": "11",
"ne_name": "NE1"
},
{
"pw_route_id": "22",
"ne_name": "NE2"
}
]
},
{
"pw_route_id": "2",
"pw_id": "22",
"pw_route_xc": [
{
"pw_route_id": "333",
"ne_name": "NE3"
}
]
}
]
}
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I think you will want something more like this:
Like this:
http://live.datatables.net/hurebeta/1/edit
You can use
columns.render
if you want to display all thene_name
inpw_route_xc
.Kevin
Thank you, this solve my problem.