kenxran / jquery-datatables-editable

Automatically exported from code.google.com/p/jquery-datatables-editable
0 stars 0 forks source link

Pause Datatable refresh Interval during edit #73

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Datatables using an Ajax data source are often set on a time interval automatic 
update. Unfortunately, such a setup can result in undesirable/inconstant 
behavior when a user manually edits a table cell. 

For these cases, it is desirable to pause the interval counter during cell 
editing. The counter should be restarted after the cell editing is completed. 
The jquery-datatables-editable
event handlers fnOnEditing, fnOnEdited are not enough for controlling 
(pause/restart) the refresh counter.

It would be nice if this option was built in.
Here is how i implemented it using the jquery plugin jquery.timer.js 

$(document).ready(function () {

    var dtTimer = $.timer();
    dtTimer.set({ action: function () { oTable.fnReloadAjax(); },
                    time:  55000   // 55 secs
    }).play(); // start the timer

    $('#myDataTable').dataTable()
                     .makeEditable({
                           oEditableSettings: {
         onedit : function (i) { dtTimer.pause(); },
         onreset: function (i) { dtTimer.play(true); }
                           },
         fnOnEditing: function(i) { dtTimer.play(true); }
    });

});

Original issue reported on code.google.com by deus...@gmail.com on 3 Nov 2011 at 1:28

GoogleCodeExporter commented 9 years ago
Minor correction to the sample code above.

$(document).ready(function () {
    var oTable;

    var dtTimer = $.timer();
    dtTimer.set({ action: function () { oTable.fnReloadAjax(); },
                    time:  55000   // 55 secs
    }).play(); // start the timer

    oTable = $('#myDataTable').dataTable()
                     .makeEditable({
                           oEditableSettings: {
                               onedit : function(i) { dtTimer.pause(); },
                               onreset: function(i) { dtTimer.play(true); }
                           },
                           fnOnEditing: function(i) { dtTimer.play(true); }
                    });
});

Original comment by deus...@gmail.com on 4 Nov 2011 at 8:59

GoogleCodeExporter commented 9 years ago
Hi,

This is not a standard request. I have never used timer and nobody til now 
requested this feature. Also, this timer is not standard so I'm not including 
third party plugins unless if they are absolutely necessary.
Can you show me some example that is widely used where this feature is 
necessary? If this is something custom  that it can be achieved using onEditing 
and odEdited methods as you have shown.

Regards,
Jovan

Original comment by joc...@gmail.com on 11 Nov 2011 at 9:33

GoogleCodeExporter commented 9 years ago

Original comment by joc...@gmail.com on 9 Feb 2012 at 9:52