I apologize in advance but I am a newbie at JS.
I have a asp.net mvc project that requires a real-time representation of data. Using datatables (jquery) ajax features I have been able to incrementally get information from the database and reload the table. However when the reload function is called the table is redrawn therefore any interaction the user had with the datatable is reset.
I think the best way to solve this problem is to detect some kind of user interaction with the datatable and temporarily pause the setincrement function (so that the table won't reload). Then wait for so many seconds after interaction and then continue to start the reload process again.
I don't know JS enough to be able to program any such detection or even pause and/or reset the incrementer. Any help would be greatly appreciated whether it be answering my question directly or with a better solution.
Here is my current JS for scripting the reload (and setting the datatable):
$(document).ready(function () {
var table = $('#myDataTable').DataTable({
autoWidth: false,
bProcessing: false,
sAjaxSource: '@Url.Action("GetDropData", "Drops")',
"columns":
[
{ "width": "10%" },
{ "width": "50%" },
{ "width": "40%" }
]
});
setInterval(function () {
table.ajax.reload(null, false); // user paging is not reset on reload
}, 500);
});