Anything to be wary of allowing Edits over a background Ajax table refresh?
Anything to be wary of allowing Edits over a background Ajax table refresh?
Essentially I would like a table to be refreshed periodically via fn.dataTableExt.oApi.fnReloadAjax but am concerned if there is an edit window open its row reference will be lost or misaligned after the refresh when the user saves the change.
Not entirely sure how such things are referenced (come to think of it, I'm not sure how Editor knows which is the primary key of the underlying table, I don't seem to specify it anywhere in the code).
Of course I could always just try it!
Is there any cause for concern?
Thanks!
Iain
Not entirely sure how such things are referenced (come to think of it, I'm not sure how Editor knows which is the primary key of the underlying table, I don't seem to specify it anywhere in the code).
Of course I could always just try it!
Is there any cause for concern?
Thanks!
Iain
This discussion has been closed.
Replies
It uses the row ID, usually given by `DT_RowId` - although 1.2.3 will introduce a new parameter called `idSrc` which allows you to change that.
However, fundamentally, yes, Editor does expect to find the same row that it started to work on when the editing is complete. Changing the rows underneath it will probably cause it to fail at the moment. Possibly to should look up the row based on the ID again when the editing is complete - that is something I will look at, but for the moment you could use the `onOpen` and `onClose` events to set a flag which will stop the refresh from happening (put a check into your setInterval, just before the fnReloadAjax call.
Regards,
Allan
I've used the flag method as suggested and it seems to work just fine.
[code]
var halt=false;
$(document).ready(function() {
editor = new $.fn.dataTable.Editor({
ajaxUrl: "./worklog.ajax.php",
domTable: "#worklog",
events: {
onOpen: function(){halt=true; },
onClose: function(){halt=false;}
}...
[/code]
[code]
setInterval(function() {
if(!halt) {
dTable.fnReloadAjax("./worklog.ajax.php");
}
}, 120000);
[/code]