updateSelectizeInput shiny 0.12

304 views
Skip to first unread message

msquatrito

unread,
May 19, 2015, 1:04:11 PM5/19/15
to shiny-...@googlegroups.com
Hi,

I've just updated to shiny version 0.12. I've noticed that it has chanced the behavior of updateSelectizeInput when `server = TRUE`. With the new version, as stated in the  package news, "The server side selectize input will load the first 1000 options by default before users start to type and search in the box". 

This is not convenient for my application and I would like it to behave similarly to the previous versions. 

I'm not familiar with javascript, is there any option of selectize.js I can use to avoid to load any options/choices until the user types in the box?

Thanks in advance.

Massimo

Yihui Xie

unread,
May 19, 2015, 5:55:21 PM5/19/15
to msquatrito, shiny-discuss
It is a little confusing when you click the selectize input and
nothing appears and you have no idea what you are supposed to do with
this input (what do the available options look like?), unless you are
familiar with selectize.js. The number 1000 is configurable thought
the option `maxOptions`. If you don't want to see that many options,
you can use a smaller maxOptions, e.g.

library(shiny)
shinyApp(
ui = fluidPage(
selectizeInput('foo', 'Foo', choices = NULL, options = list(maxOptions = 5))
),
server = function(input, output, session) {
updateSelectizeInput(session, 'foo', choices = letters, server = TRUE)
}
)

Does that sound satisfactory to you?

Regards,
Yihui

msquatrito

unread,
May 20, 2015, 4:48:58 AM5/20/15
to shiny-...@googlegroups.com, squa...@gmail.com
Dear Yihui,

I see your point, however in my selectize input I have a placeholders that explain what to enter:

shinyApp( 
  ui = fluidPage( 
    selectizeInput('foo', 'Foo', choices = NULL, options = list(placeholder = "Enter letter, eg: a")) 
  ), 
  server = function(input, output, session) { 
    updateSelectizeInput(session, 'foo', choices = letters, server = TRUE) 
  } 

I have a very long choices character vector (approximately 20.000 gene names), I don't need any of the to be shown (not even 5). I liked as it was before this new update, so that in the option list appear only the choices that match with what the user is typing.
Something like:

my_choises <- c("aa","ab","ac", "bb", "bc", "bd")
shinyApp
(
  ui
= fluidPage(
    selectizeInput
('foo', 'Foo', choices = NULL, options = list(placeholder = "Enter letter, eg: a"))
 
),
  server
= function(input, output, session) {
    updateSelectizeInput
(session, 'foo', choices = my_choises, server = TRUE)
 
}
)

 I would like that from the beginning the choices that contain "a" appear only when the user type "a".

Thanks.
Best,
Massimo 
 

Yihui Xie

unread,
May 20, 2015, 11:49:59 AM5/20/15
to msquatrito, shiny-discuss
Users can still type in the text input to filter the gene names even
if the first 1000 (or 5) choices are loaded initially, so I'm not
quite sure what really hurts. The initial options only give users a
sample, and they don't necessary have to use any of these options. I
have been told by some users that the old behavior was confusing
(nothing appears initially), and I tend to agree with them.

Regards,
Yihui

msquatrito

unread,
May 20, 2015, 12:50:00 PM5/20/15
to shiny-...@googlegroups.com, squa...@gmail.com
Nothing "really hurts", I just preferred the old way :-). 
I've the impression that if the options are shown the user could spend/waste time (or get confused) in going through the option list instead of just typing right away. I guess that for a small list of options is ok to show them, but for a long one I don't think is that helpful.

Anyway, thanks a lot for your feedback!

Best,
Massimo

Yihui Xie

unread,
May 20, 2015, 4:31:42 PM5/20/15
to msquatrito, shiny-discuss
Thanks for your understanding. If you really hate the new behavior, I
can find time to add an option to selectizeInput() to disable the
initial options. Please just file a request to
https://github.com/rstudio/shiny/issues

Regards,
Yihui
Reply all
Reply to author
Forward
0 new messages