How to populate data from json format into data table and keep datatable properties

  Kiến thức lập trình

I have been able to get data into data table from json format via ajax,But suddenly data table lost some properties that enable it to search and allow pagination on page. But the results can be viewed as an array via console.log, And all data are coming as a result on long table, But on document.ready function the table before i change the control appears well with all the functionalities

1- I tried to polulate it via js using by declaring and enable the properties as follow: $(‘#assets’).DataTable({
paging: true,
scrollX: true,
lengthChange : true,
searching: true,
ordering: true
}); and Showing 0 to 0 of 0 entries (filtered from 1 total entries)

2- Alternatively

.done( function(data) {
$(‘#example’).dataTable( {
“aaData”: data,
“columns”: [
{ “data”: “id” },
{ “data”: “name” },
{ “data”: “detail_alias” },
{ “data”: “points” }
]
})
})

I tried different method from different sources and red datatable resouces but didn’t work.
I googled for long without getting an answer

LEAVE A COMMENT