Category: How do I do X?
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How do I make a disabled row unselectable?

Issue

I have a CRUD app with a table of items. I want to allow users to select multiple rows and delete them, but I need to keep at least one row in the table. I tried disabling the row, but it can still be selected. I don't want to disable the delete button because users could still select all the items and delete them. I need a way to programmatically deselect a row or prevent the disabled row from being selected. I tried using storeValue to set the default selected rows, but the onRowSelected event doesn't trigger when deselecting a row or using the "select all" checkbox.

Resolution

The problem is that a CRUD app needs to be able to delete rows, but there should always be at least one row left in the table. The proposed solution is to disable the delete button when there is only one row, or create a JS function that triggers a warning when the user tries to delete all rows. However, the user can still select the disabled row, which is not ideal.

To prevent the user from selecting the disabled row, one suggestion is to use storeValue and set the Default Selected Rows of the table. This way, the developer can programmatically deselect a row and ensure that at least one row is always selected. However, the onRowSelected event doesn't get triggered when deselecting a row, nor when using the "select all" checkbox.

In summary, the best solution depends on the specific needs of the CRUD app. Disabling the delete button or using storeValue to set Default Selected Rows are both viable options, but the latter requires more advanced programming skills. Regardless of how the developer chooses to implement the solution, the goal should be to prevent the user from deleting all the rows in the table.