Display data with JSON string.
Display data with JSON string.
abhinavp18
Posts: 1Questions: 1Answers: 0
I have a function which has a parameter of JSON string. I am not able to show data in table using that string.
items = "{"items":[{"featureId":"16","name":"weqrds","featureDescription":"","version":"","deployed":false,"enabled":true},{"featureId":"15","name":"weq","featureDescription":"","version":"","deployed":false,"enabled":true},{"featureId":"14","name":"wqer","featureDescription":"","deployed":false,"enabled":true},{"featureId":"13","name":"s","featureDescription":"","deployed":false,"enabled":true},{"featureId":"12","name":"we ","featureDescription":"","deployed":true,"enabled":true},{"featureId":"11","name":"f65 ","featureDescription":"","deployed":true,"enabled":true},{"featureId":"10","name":"ff5 ","featureDescription":"","deployed":true},{"featureId":"9","name":"f4 ","featureDescription":"","deployed":true,"enabled":true},{"featureId":"8","name":"F3 ","featureDescription":"","deployed":true,"enabled":true},{"featureId":"7","name":"F2 ","featureDescription":"","deployed":false,"enabled":true},{"featureId":"6","name":"F1 ","featureDescription":"","deployed":false},{"featureId":"5","name":"Memo ","featureDescription":"","deployed":true,"enabled":true},{"featureId":"4","name":"3D ","featureDescription":"","deployed":true,"enabled":true},{"featureId":"3","name":"Reports ","featureDescription":"","deployed":true,"enabled":true},{"featureId":"2","name":"Save","featureDescription":"","deployed":true,"enabled":true}]}"
function createTable(items){
$('#example').dataTable( {
"scrollY":"200px",
"scrollCollapse": true,
"paging":true,
"columns": [
{ "data": "name" },
{ "data": "featureDescription" },
{ "data": "featureId" },
{ "data": "version" },
{ "data": "deployed" }
]
} );
}
This discussion has been closed.
Answers
I don't see where you are actually using
items
, however it is a string, so you need to confirm it to be "JSON". UseJSON.parse()
to do so - MDN documentation.Allan