- Goal: How do I hide the view within the container using javascript
Hi @Pooja_Ramani,
Welcome to Retool!
To hide a view or almost any component, just set the Hidden value to true. In the example below I have a littel Javascript to check if checkbox1
is true {{ checkbox1.value }}
.
@Shawn_Optipath thanks for the repliy, but I am looking to hide it via the script, something like setHidden, but I cant find such functionality for the view. Thanks
There are plenty of ways you can hide the view. Another way is to create a variable hideView1
and set its initial value to false
. Then use JS to set this value hideView1.setValue(true)
.
Can this not be done just be using the conatiner and the view name in the javascript? Above suggested solution still require using the UI
Yes, if you want to set the value in JS you can create a JS Query and add hideView1.setValue(true)
. Then just click run and it will hide the view.
You will still need to add hideView1.setValue(true)
in the Hidden filed in the view for this to work.
So there is no solution to disable/hide it purely via the name of the container->view, the only solution available is to do it via UI?
The last example I gave you was via a script, not the UI. I do not believe there is a way "purely via the name" but my example works and is fairly simple to implement.
I have got a lot of containers with a number of views within them, and it becomes very difficult if you have to go into the ui of each view and set the value. It was easier if there was function to setHidden for the views like other components. Thanks
You can always ask for the feature in Feature Requests. The Retool team is pretty reactive. In the meantime, you have a workaround.
Thanks, @Shawn_Optipath! I'll mark your answer as a workaround/solution for now.
@Pooja_Ramani thanks for the feedback - I'll make a feature request for this