DataTables Editor Buttons Conditionally Enable / Disable

DataTables Editor Buttons Conditionally Enable / Disable

Ali AdnanAli 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

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    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

  • naspersgaspnaspersgasp Posts: 53Questions: 14Answers: 1

    Thanks, worked for me. Needed the editor in readonly mode. :smile:

This discussion has been closed.