Enable/Disable individual tab from JavaScript

- Goal: Depending on the user of the app (they enter their name which is checked) I want to disable/enable some tabs of a Tab component.

I am testing with a script attached to a button so I am pretty sure it is being fired.

- Steps: I have tried assigning and array constant as suggested by the chatbot

i.e. tabsComponentName.disabledByIndex = [false, true, false]; // Enables the first tab, disables the second, enables the third

This fails silently.

None of the data for Disabled has a setValue method.

Copilot and Google have only led me down blind alleys!


Any help much appreciated. Thanks.

John

Hi John,

Thanks for reaching out! Retool properties like disabledByIndex are read only; unless there is a setValue property, you can't set the value in a script. tabsComponentName.disabledByIndex = [false, true, false]; will not work. but you can make the disabled property dynamic like this:

  1. Create a variable that will track your array of booleans for disabled:
  2. Write some code to update the variable based on the name

  1. Pass part of the variable into each corresponding tab


etc.

Assuming this is not a public app, you could also skip the name input and just reference {{current_user}}

Tess. Thank You - particularly for the great detail with screenshots.

I am new to "low-code" frameworks so too ready to jump in to try coding and falling foul of the "missing" setValue method. Dynamic values are a more transparent solution for readers of an App's design too.

1 Like