jrowen / rhandsontable

A htmlwidgets implementation of Handsontable.js
http://jrowen.github.io/rhandsontable/
Other
383 stars 148 forks source link

hot_to_r fails for rhandsontables based on matrix objects #359

Open ismirsehregal opened 4 years ago

ismirsehregal commented 4 years ago

rhandsontable objects created using a matrix object cannot be converted back to R via hot_to_r. As shown in the below example the conversion seems to be limited to data.frames:

library(shiny)
library(rhandsontable)

ui <- fluidPage(
  rHandsontableOutput("myTable"),
  tableOutput("my2ndTable")
)

server <- function(input, output, session) {

  # output$myTable <- renderRHandsontable({rhandsontable(as.data.frame(matrix(c(1:25) * i, ncol = 5, nrow = 5)))}) # works
  output$myTable <- renderRHandsontable({rhandsontable(matrix(c(1:25) * i, ncol = 5, nrow = 5))}) # doesn't work

  output$my2ndTable <- renderTable({
    hot_to_r(req(input$myTable))
  })

}

shinyApp(ui, server)
Warning: Error in genColHeaders: Change no recognized:afterChange
  105: stop
  104: genColHeaders
  103: <Anonymous>
  101: hot_to_r
  100: renderTable [~/.active-rstudio-document#14]
   99: func
   86: origRenderFunc
   85: output$my2ndTable
    5: runApp
    3: print.shiny.appobj
    1: source

I saw this problem here first.