Grey Out on Radio Button Selection

1,545 views
Skip to first unread message

Jonathan

unread,
May 13, 2014, 9:31:18 AM5/13/14
to shiny-...@googlegroups.com
Hello,

When I set a radio button to true, I'd like to "grey out" (make inactive) some other input widgets, rather than remove them from the UI altogether. Any suggestions?

Jonathan

Aurelien Tylski

unread,
May 13, 2014, 9:32:51 AM5/13/14
to shiny-...@googlegroups.com
Hey,

did you try to use RenderUI ?

Jonathan

unread,
May 14, 2014, 2:26:26 PM5/14/14
to shiny-...@googlegroups.com
Yes, I can use renderUI to remove the widget from the UI altogether. I want the widget to stay there but I want it to become "inactive" or "greyed out". 

So the real question is just: how to make an inactive widget in general?

Jonathan

Jonathan

unread,
May 15, 2014, 7:33:16 AM5/15/14
to shiny-...@googlegroups.com
I found this question at stackoverflow, which is nearly the same. It points to a javascript solution for actionButtons, but doesn't work for other widgets. There's no response to the question. Does anyone know why the javascript works for actionButton but not for other widgets?

Jonathan

unread,
May 23, 2014, 11:50:36 AM5/23/14
to shiny-...@googlegroups.com
How about this approach? I tried this example http://shiny.rstudio.com/articles/html-ui.html to build UI with html code.

In this example, when I change from <select name="dist"> to <select name="dist" disabled=true>
and change from <input type="number" name="n" value="500" min="1" max="1000" /> to
<input type="number" name="n" value="500" min="1" max="1000" disabled=true />

it behaves exactly like what I want and need. So the question is: how can I use selectInput() and numericInput() to specify the "disabled" attribute? Then I can use renderUI() to change it.

I think I could figure this out using the shiny::tags to bypass using selectInput() and numericInput() and specify the attribute. But this seems like it should just be a simple option to the *Input() functions. Also, I'm trying to figure this out on behalf of other folks writing Shiny apps, who would rather keep it at the easier level of using selectInput() and numericInput() level rather than delving into custom HTML code.

Jonathan


Reply all
Reply to author
Forward
0 new messages