Reload table with the same properties and with the updated json data
Reload table with the same properties and with the updated json data
whatacar
Posts: 7Questions: 3Answers: 1
I am newbie here and I am reloading the table using destroy() method...I know, it's a bad approach. Can you, please, recommend me the appropriate method (approach) of doing this. Your answer or any hint on this would be highly appreciated. Thank you in advance in any case.
$(document).ready(function () {
$('#sbmt').on('click', function () {
var table
var content = { "s": $("#s").val(), "a": $("#s").val() }
if (!$.fn.dataTable.isDataTable('#example')) {
table = $('#example').DataTable({
"ajax": {
"url": 'json_out.asp',
"type": 'POST',
"data": content,
"dataSrc": "",
"deferRender": true
},
"columns": [
{ "data": "product_id" },
{ "data": "material_num" }
]
});
}
else {
table = $('#example').DataTable({
destroy: true,
"ajax": {
"url": 'json_out.asp',
"type": 'POST',
"data": content,
"dataSrc": "",
"deferRender": true
},
"columns": [
{ "data": "product_id" },
{ "data": "material_num" }
]
});
}
} );
} );
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Have you looked at https://datatables.net/reference/api/ajax.reload() option?
thank you bindrid for your for your support :-). Here is the working code using ajax.reload().