DataTables Editor Buttons Conditionally Enable / Disable
DataTables Editor Buttons Conditionally Enable / Disable
Ali Adnan
Posts: 47Questions: 18Answers: 1
Dear Allan,
I have requirement to stop "Edit and Delete" functionality if Value of one column = 1 in a selected Row (Single Edit Mode).
How can I achieve this ?
I have tried
Declaration_Table.on('select', function (e, dt, type, indexes) {
Declaration_Table[type](indexes).nodes().to$().addClass('DTTT_selected');
var P_DECL_STATUS = Declaration_Table.row({ selected: true }).data().si_declr.status;
Declaration_Table.buttons(['.edit', '.delete']).enable(Declaration_Table.rows({ selected: true }).indexes().length === 0 && Declaration_Table.row({ selected: true }).data().si_declr.status == 0 ? false : true);
});
but nothing happened.
Best Regards
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Do you want the row to be selectable at all? If not, the easiest option is to use the
user-select
event to cancel the row select on those rows.If the row should still be selectable, rather than attempting to override the enable / disable of the built in edit and delete button types (as that will cause an unpredictable conflict) create a custom button that will enable and disable based on your required logic.
Regards,
Allan
Thanks, worked for me. Needed the editor in readonly mode.