Hi Retool Team,
Is there a way to "select all rows", or "check all checkboxes in each row" of a table?
My use case is:
- I have a table, in which the user can select multiple rows via checking the check box
- The checkbox column is a custom column of the table, with type = checkbox
- The user now needs to select row by row
- Is there a way to "select all" checkboxes, please? I am thinking along the lines of a JS query that sets the checkbox status to "True" for the checkbox column
Hey @oliver.ng — thanks for the great question! Yes you can write a JS query to select all rows in the table with the native
table.selectRow() function that we expose. Here's an example:
You can even assign this as a custom button in the table footer. Here's a GIF:
Thanks Alex, that is very helpful.
- Is there a way to use the table.setData() function to set the checkbox column to be true for all rows
- And such update would trigger the recordUpdates property of the table component.
Hi @oliver.ng I don't think you can access recordUpdates when updating with setData, but I think that general concept will still work:
First, use a JS query to temporarily update the table data with the checkboxes all set to true:
Then, on success, trigger a bulk update query:
@Tess thanks. this is very helpful. is there anyway at the moment to programatically access recordUpdates at the moment or it can only be done manually?
Potentially a useful feature request down the road.
@oliver.ng Do you mean to update the values inside of tablename.recordUpdates?
yes that is what I mean - updating the values of tablename.recordUpdates programatically other than just from the frontend UI
Got it! Unfortunately
.recordUpdates is currently only read-only
Is this expected?
Hi @ryguy022 It should still work for a dynamic table. In the cases where it isn't working, is tableName.data formatted as an array? If not, you may need to wrap the data input in formatDataAsArray():
Also, be sure that selection mode for the table is set to multiple!