How to change table custom column values programmatically?

Hello! I have a table with a custom column with "Checkbox" type to select entries in columns for bulk state change (enabled/disabled). I want to create a button with "Select All" action, to set all checkboxes to true.
The issue, that I can't use table.setData(), as custom columns are not part of original data. I've tried to edit table.changeSet and table.Record updates, but without any luck.

Is it any approach, to update custom columns or should I found the way with the default "Allow selecting multiple row" feature? (Which is not the best solution for me, as I have an entry edit for attached to table.selectedRow.)

Thanks for your help!

Hey yauheni! One workaround here would be to append a boolean column to your table data itself. This way, the checkbox column would not be a custom column and you could use table.setData to set all of the checkboxes to true programmatically. You would need to both append and remove a boolean field to the data that populates your table when pulling it into and passing it out of Retool using a JS transformer or a JS query.

Here's an example of what this could look like

You can add a transformer to your query to add the boolean field. You'll want to set the values to null so that its possible to track any changes in the table.recordUpdates value.

You can then have a button or some other UI action trigger a query that sets all the 'Selected' fields to true using the table2.setData method.

And you could then set up a transformer to return only the rows where 'Selected' has been set to true and to remove the selected field from those rows so you don't have to worry about dealing with the added field on the backend.

I hope that makes sense and can work for your use case :grinning_face_with_smiling_eyes:

Thanks a lot for introducing me to the additional approach, looks great! Will try to apply for my case.

Hi !

I've exactly the same requirement: propose a button to 'prefill' some updates on a table to facilitate data provisionning before hitting 'save' and triggering the bulk update.

Your solutions works for setting the new datas (i've tested on several columns, including a "test" column pre-set to null in a transformer as you suggested).

But neither recordUpdates nor changeSet are updated (and we can see in the cells are not yellow) and the SAVE button is not displayed in the table.

Before:

After:

table_after_no_changeset

table_after_no_recordupdate

Code:

table.setData(table.data.map(d => { 
  d["responsible_condi"] = "tututoto";
  d.ok_condi = true;
  d.count_condi = d.quantity_to_condi;
  d.test = true;
  return d;
}));

am I missing something ?

Thanks,
Regards,
Thomas

Hey Thomas — I believe with this setup since you are changing the input data rather than explicitly making these changes, recordUpdates and changeSet would not change until a user makes a change to your dataset manually. I don't think there is any way to programmatically change values in a custom column at the moment that are also reflected in these properties.

Hi damn, this it too bad.

But wait: I my case the columns are not custom columns, but columns from the table.data
Do you think there is another approach to progammatically change values of table 'standard' columns that can be reflected in changeSet and recordUpdates ?