A plug in for jquery DataTables to enable inline editing
$('#my-table').DataTable().editable_table();
Callback invoked before beginning to edit a row. The order of execution is:
- user clicks a row to edit
- any rows currently being edited (any
tr
with classbeingEdited
) are saved (DataTables internal data is updated with the contents of the input fields). beforeEditStart
is called, if present.beingEdited
class is applied to thetr
to be edited- input fields are created
afterEditStart
is called, if present.
If beforeEditStart
returns false
, then editing does not start.
$('#my-table').DataTable().editable_table({
beforeEditStart: function() {
if (cant_edit_right_now) { return false; }
console.log('Editing starting.');
}
});
Callback invoked after the user begins editing a row (after the input fields have been created).
$('#my-table').DataTable().editable_table({
afterEditStart: function(aData, tr) {
$tr.addClass('edit-highlight');
aData.modified = true;
}
});
Use this command to end editing. Input fields are removed, and user input is copied to DataTables' internal data.
$('#my-table').DataTable().editable_table('close');