5

When I try to edit the entries of an rhandsontable inside a Shiny app, the drop-down menus are cut short. Is there a way to make them fully expand like the date selectors in the rhandsontable tutorial? Here is the app.

library(rhandsontable)
library(shiny)

ui = fluidPage(rHandsontableOutput("data"))

server = function(input,output) {
  df = data.frame(x = factor(letters[1:3], levels = letters))
  values = reactiveValues(data = df)

  observe({
    req(input$data)
    values$data = hot_to_r(input$data)
  })

  output$data = renderRHandsontable({
    rhandsontable(values$data) 
  })
}
shinyApp(ui = ui, server = server)
landau
  • 5,636
  • 1
  • 22
  • 50

1 Answers1

6

It will work if you change the size of your rhandsontable.

You could try:

library(rhandsontable)
library(shiny)

ui = fluidPage(rHandsontableOutput("data"))

server = function(input,output) {
  df = data.frame(x = factor(letters[1:3], levels = letters))
  values = reactiveValues(data = df)

  observe({
    req(input$data)
    values$data = hot_to_r(input$data)
  })

  output$data = renderRHandsontable({
    rhandsontable(values$data, height=500) 
  })
}
shinyApp(ui = ui, server = server)

EDIT: Based on this, you can use overflow = "visible". It seems to fix the issue.

ui = fluidPage(rHandsontableOutput("data"))

server = function(input,output) {
  df = data.frame(x = factor(letters[1:3], levels = letters))
  values = reactiveValues(data = df)

  observe({
    req(input$data)
    values$data = hot_to_r(input$data)
  })

  output$data = renderRHandsontable({
    rhandsontable(values$data, overflow = "visible") 
  })
}
shinyApp(ui = ui, server = server)
MLavoie
  • 9,671
  • 41
  • 36
  • 56
  • Can you change the width of the menus too? Without increasing the width of the column. – Simon Woodward Oct 08 '20 at 20:14
  • This solution is not great because we can't vary the number of rows in the table or page size. I tried min-height in the css but then the dropdown stopped working. – Frank Jan 04 '21 at 23:36
  • Hi, is there another way to do that without touching the height of the table, which is not ideal? (in case of relative long dropdown compared to number of rows of the table for instance). Maybe by setting the z-index of the dropdown menu to a high value? – yeahman269 Mar 11 '21 at 15:24
  • @yeahman269, see edit. Does this work for you? – MLavoie Mar 11 '21 at 19:48
  • Unfortunately, no it does not. Already tried it. The drop down menu is still truncated if `height` is not sufficient. – yeahman269 Mar 12 '21 at 10:44
  • 1
    @yeahman269, maybe it's worth posting a new question with your data reproducing your problem. – MLavoie Mar 12 '21 at 11:10