How to add a checkbox to each row in a table, and being able to check a box and save it

I have a table that I built through querying our database. I want to add a column which is a checkbox (boolean). For each row, I need to perform some action in our system, and afterwards I want to check the box in that row so that people know the action has been performed. How do I do that?

1 Like

Hello @wwhhxx0324 and welcome!

Consider that if the table data is displaying data directly from a query to a database source, affecting changes on the data requires that the database be updated, after which the table data must be refreshed.

Your post title seems to be about how to add an editable boolean column, but your post body seems to indicate that you want to use a row action to process information and then have the "finished" result indicated by a value in the table. You can do this, however I was wondering if you could expand slightly on the use case so the forums can offer you the best available options.

2 Likes

Thanks for the reply! To clarify the use case: I have a table in Retool showing people I need to disburse cashback to. Once I pay the cashback using our app (outside of Retool), I want to come back into Retool and manually mark that cashback as paid.

So I’m hoping to add a checkbox column to the table that’s backed by a boolean column in the database (e.g., cashback_paid). When I check the box, it should update that row in the Retool table and save the change. This way, others can also see which rows are already marked as paid.

What’s the best way to make that checkbox editable and save the update?

In this case, the first thing to do would be find the Boolean column you have setup from your DB in the Retool table's column properties and mark it as editable. From your screenshot, it looks like there is already a Save Action handler in the table, but this needs to be connected to a query that will update your DB with the changed row data.

You can do this by accessing the table's changesetArray or changesetObject properties within the query you are using to write back to the DB.

A basic look for the column setup:

The table's Save Action addon:

A query to update a DB table:

There is also a table setting to "include full row data" in the changesetArray which you might need depending on how your table/keys are setup in both systems. It is in the table properties nestled in the Interaction menu:

I hope this helps get you going!

1 Like