enable/disable buttons not working on search event

enable/disable buttons not working on search event

abanetabanet Posts: 9Questions: 2Answers: 0
edited January 2023 in Free community support

Hi,

I have a Datatable with some buttons: the edit and remove buttons for the editor and one custom button. I need to enable/disable this buttons when the user select/deselect a row.

This is working perfectly: (my custom button has a className called 'gestion'.)

    tablaAsignaturaOtra.on('select deselect', function () {
                    var selectedRows = tablaAsignaturaOtra.rows({selected: true}).count();
                    tablaAsignaturaOtra.button(['.edit', '.delete', '.gestion']).enable(selectedRows === 1);
                });

But then I realized that I need to do the same if the user use the search box and there is not any row selected in the result of the search so I added the search event:

tablaAsignaturaOtra.on('select deselect search.dt', function () {
                var selectedRows = tablaAsignaturaOtra.rows({selected: true, search: 'applied'}).count();
                tablaAsignaturaOtra.button(['.edit', '.delete', '.gestion']).enable(selectedRows === 1);
            });

The problem I got is that this is working perfectly for the custom button, but for the edit and delete buttons the function is called but this two buttons remains enabled.

Am I doing something wrong? Thanks in Advance!

Answers

Sign In or Register to comment.