editor with multi select and disable button not working

editor with multi select and disable button not working

jfrjfr Posts: 71Questions: 24Answers: 0

Hi
I am triing to disable the edit button when more than 1 row is selected
I have tried

        .on("select", function (e, datatable, settings, processing) {
                var selectedRows = datatable.rows( { selected: true } ).count();
                if (selectedRows != 1) {
                oTable.buttons( ).disable();
                // datatable.button( 1 ).disable();
                // datatable.button( "edit:name" ).disable();
                } else {
                datatable.button( "edit:name" ).disable( selectedRows != 1 );
                datatable.button( "edit:name" ).enable( selectedRows === 1 );
                }
    })

The create button does become disable but not the edit or delete button

Thanks in advance

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    The best way to do this would actually be to use the selectedSingle button type. Let it do the button enable and disable actions for you and just define an action function that will trigger edit() on the selected row when the button is activated (this button type can only be activated when a single row is selected).

    Editor's buttons extend the selected button, and they control their own enable / disable state, which is why you will be running into problems with the above approach.

    Allan

  • jfrjfr Posts: 71Questions: 24Answers: 0

    Hi Allan
    Exactly what I was searching for
    Thanks

This discussion has been closed.