Rhandsontable non-consecutive cell selection in shiny app

446 views Asked by At

I am trying to use Rhandsontable in a Shiny app to make a 8x12 table that will be used as input matched to a 97 column dataframe. Each cell in the table corresponds to 1 column in the dataframe (-1 for the x-axis).

This is my current code for testing:

server <- function(input, output) {

  mat = matrix(, nrow=8, ncol=12, dimnames= list(LETTERS[1:8],1:12))

  output$table = renderRHandsontable({
    rhandsontable(mat, readOnly = T, selectCallback = T) %>% 
      hot_cols(colWidths=22) %>%
      hot_context_menu(allowRowEdit = FALSE, allowColEdit = FALSE)
  })

  output$selected=renderPrint({
    cat('Selected Row:',input$table_select$select$r)
    cat('\nSelected Column:',input$table_select$select$c)
    cat('\nSelected Cell Value:',input$table_select$data[[input$table_select$select$r]][[input$table_select$select$c]])
    cat('\nSelected Range: R',input$table_select$select$r,'C',input$table_select$select$c,':R',input$table_select$select$r2,'C',input$table_select$select$c2,sep="")
  })

}

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(width=5,
                 rHandsontableOutput("table"),
                 verbatimTextOutput("selected")
    ),
    mainPanel(

    )
  )
)

shinyApp(ui,server)

This works great for shift-click based multiple selection, selection of whole rows, whole columns, and single cells. However, I need to be able to select also in the standard cntrl+click way to select discontinuous blocks of cells. Is this not feasible in rhandsontable package? I can't find any documentation on it, nor can I find anything else on SO. Help or recommendations on what packages/tools can accomplish this would be greatly appreciated.

0

There are 0 answers