I have a CRUD app and a table with item in a row. The idea is to be able to select items and then click a button to delete those items. However, I need to keep at least one item in the table. I can set it to disable a row, but the row is still able to be selected. Is there a way to make it so the disabled row cannot be selected, or at least, maybe immediately deselect the row?
That won’t really work for this scenario. Say there are 5 items. They could still select all 5 items and delete them in that case.
Hi! You could try to restrict the user to select and delete all rows of the table by disabling the Delete button if Table1.selectedRows.length==Table1.tableData.length
.
That could work if I can’t get anything else. Just a bit confusing for the user.
Or you could create a JS function inside a JS Object that you run in the onClick
event of the Delete button, where, based on this condition, you either trigger the delete query or show an alert to warn the user that they are not allowed to delete all rows.
Is there any way I can programmatically de-select an item? I have a function that will check the condition but I haven’t found a way to select it. I removed the item from the selectedRows but it didn’t seem to work.
That won’t work. The only way to do this would be to use storeValue to set the Default Selected Rows of the table.
I thought I could make it work using storeValue and setting the Default Selected Rows but unfortunately, the onRowSelected event doesn’t get triggered when deselecting a row, nor when using the “select all” checkbox at the top of the column.