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 successful to run datatable at one time as below code
$(document).ready(function () {
$("#TableCurrentList").hide();
$('#datetimepicker1').datetimepicker();
$('#datetimepicker2').datetimepicker();
$('#cmdList').on('click', function () {
$("#TableCurrentList").hide();
// $("#TableCurrentList").DataTable().clear().draw();
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",
"data": {"datefr" : $("#txtDateFr").val(), "dateto" :$("#txtDateTo").val() }
},
"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": "dtRecDateTime", "name": "dtRecDateTime", "autoWidth": true },
{ "data": "fCurrentW", "name": "fCurrentW", "autoWidth": true },
]
});
});
});
But when I click again, I get initialize error. it seem need to add table reload on every click. Can I know to do it ?
Thank you
This discussion has been closed.