Using rhandsontable in a Shiny app, I want to detect when the user deselects a row. In this example, when I click a row, I can detect the selection with input$mytable_select$select$r, but when I click outside the table, input$mytable_select$select$r is still set to the row number even though the row is no longer highlighted. I could create a button and when the user clicks it, reload the rhandsontable, but I would prefer not to do this.
require(shiny)
require(rhandsontable)
shinyApp(
ui = fluidPage(
rHandsontableOutput("mytable")
),
server = function(input, output, session) {
output$mytable <- renderRHandsontable({
rhandsontable(
data = mtcars,
selectCallback = T
)
})
observe({
if(is.null(input$mytable_select$select$r)) {
print("No rows selected")
} else {
print(paste0("Selected row: ", input$mytable_select$select$r))
}
})
}
)