How to reload table on each button click
How to reload table on each button click
laputatc
Posts: 4Questions: 4Answers: 0
Hi All
I have success to run datatable from server side as below code
$(document).ready(function () {
$("#TableCurrentList").hide();
$('#cmdList').on('click', function () {
$("#TableCurrentList").hide();
var url = '@Url.Action("GetElecticList1", "Home")';
$("#TableCurrentList").show();
$("#TableCurrentList").DataTable({
"processing": true, // for show progress bar
"serverSide": true, // for process server side
"filter": true, // this is for disable filter (search box)
"orderMulti": false, // for disable multiple column at once
"pageLength":13,
"ajax": {
"url": url,
"type": "POST",
"datatype": "json"
},
"columnDefs":
[{
"targets": [0],
"visible": false,
"searchable": false
},
{
targets: 1,
render: function (data) { return moment(data).format('YYYY/MM/DD HH:mm:ss'); }
}
],
"columns": [
{ "data": "id", "name": "id", "autoWidth": true },
{ "data": "RecDateTime", "name": "RecordTime", "autoWidth": true },
{ "data": "fBrenchMark", "name": "BrenchMark", "autoWidth": true },
]
});
});
});
But I click again, I go the initialize error , it seem serverside datatable need to do clear / reload on every click, and I have try but not success, can anyone help ?
Thank you
Mike
This discussion has been closed.
Answers
You could try adding
destroy
to the initialisation arguments.Colin