Change columnEditable from false to true

Hi Everyone,

I'm new to Retool, and I'm hoping that someone can help me with an issue. I am dynamically adding a new column to a table in MS SQL. After the new column is added, the table component is refreshed and reflects the new column. The problem that I'm having is that the column defaults to columnEditable = false, and I need columnEditable to = true.

In the screenshot, you will see that the success event handlers are creating a notification, refreshing the table component then running the script to update columnEditable to false for the newly added column. Then it clears the text value from the column.

I'm not receiving an error, but the column remains un-editable.

Thank you in advance for the help!

Hey @jkling!

Happy to help with this.

In general, Retool doesn't support the pattern of component.value = false. Instead, Retool uses methods, like component.setValue(false). There are a limited number of these setter methods (some components have .setHidden(true), for example, but some don't) so imo, the best way to figure out which setters are accessible by a specific component is to just type the component name followed by a . (e.g. textInput1.) to bring up the autocomplete menu and look for all the options in the Function category.

In your specific example, would dynamic column settings help? There's a restrictedEditingMapper setting.

https://docs.retool.com/docs/data-in-tables#dynamic-column-settings

As I think about it, if you need to do this for all new columns, you may need to run a separate JS transformer on success of your add column query and have it return a new object that contains the name of your new column and the applicable properties. Then, in your table's dynamic column settings field, you can reference {{transformer1.value}} to make sure the new column is included every time!

Anyway, let me know if you're able to make some progress here and let me know if you have any questions :slight_smile:

Hi @victoria. Thank you for your response. I'm new to Retool, and I couldn't figure out either option. I like the transformer option because I need it to unlock all columns. I am skilled enough to write the transformer (I'm learning tho). Could you help me write it?

Definitely happy to help! I was trying to set up the transformer and I think we be running into a fatal flaw :pensive:

It seems like we can set restrictedEditingMapper to true and it'll prevent columns from being edited, but setting it to false does nothing (even though it should do the reverse).

I'll check in with my team now to see if there's any way we can work around this!

let settings_arr = []
for (const key in {{query2.data}}) {
  settings_arr.push({name: key, restrictedEditingMapper: false})
}

return settings_arr;

1 Like

@victoria, thank you for all your help! I read your first response that said you were reaching out to your team, then posted your screenshot. It was unclear if the screenshot meant that you resolved the issue or if you were showing me what you had done that was not working.

Nonetheless, I replicated what you did, and it's not working for me. The transformer ran fine, but it didn't seem to make any impact. Any thoughts?

I really appreciate all of your support.

Hey @jkling, so sorry about the confusion here and sorry for the delay in getting back to you (it's been a busy few weeks!).

I showed you what we could do if the restrictedEditingMapper: false setting would actually work to make the column editable.

It doesn't look like there's another way to create new columns and make them editable on the column by default until this setting works :pensive: