Is is possible to disable the Edit button when a selected row is filtered out by a search?

Is is possible to disable the Edit button when a selected row is filtered out by a search?

sbaysbay Posts: 2Questions: 1Answers: 0

Is is possible to disable the Edit button when a selected row is filtered out by a search?

For example:
1. Go to https://editor.datatables.net/
2. In the example table, click on the first row (Name: Airi Satou)
3. Notice the "Edit" button is enabled
4. In the Search field, enter something which filters out the selected row (eg. "London")
5. Notice the row selected in step 2 is no longer shown, but the "Edit" button for it is still enabled

Is there a way to disable the Edit button for such a case?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,652Questions: 1Answers: 10,094 Site admin
    Answer ✓

    Not with the edit button I'm afraid. The row is still selected, so I think it is correct that it be edited. What we really need here is some kind of de-select when filtered out option (although that might be annoying if you filter a row out, then bring it back in and find it deselected?).

    To get what you are looking for at the moment, you'd need to call edit() from a custom button and select only visible selected rows:

    var rows = table.rows({selected: true, search: true}).indexes();
    

    And pass those indexes into edit().

    Allan

  • sbaysbay Posts: 2Questions: 1Answers: 0

    Thanks! I appreciate the quick response.

Sign In or Register to comment.