How can I reset the selected cell range each time a new dataset is generated in the example below?
library(shiny)
library(data.table)
library(rhandsontable)
shinyApp(
ui = fluidPage(
actionButton('gendata', 'Generate data'),
hr(),
verbatimTextOutput('verb'),
hr(),
rHandsontableOutput('table_original'),
hr(),
rHandsontableOutput('table_subset')
),
server = function(input, output, session) {
mydata <- reactive({
req(input$gendata)
n_dim <- sample(2:8, 1)
data.table( matrix(rnorm(n_dim**2), n_dim, n_dim) )
})
output$table_original <- renderRHandsontable({
req(mydata())
rhandsontable(data = mydata(), selectCallback = TRUE)
})
output$table_subset <- renderRHandsontable({
req(input$table_original_select$select)
selected_rows <- input$table_original_select$select$rAll
selected_cols <- input$table_original_select$select$cAll
DT <- hot_to_r(input$table_original)
DT <- DT[selected_rows, ..selected_cols] # subset
rhandsontable(DT)
})
output$verb <- renderPrint({
str(input$table_original_select$select)
})
}
)
Via Active questions tagged javascript - Stack Overflow https://ift.tt/avVxGoY
Comments
Post a Comment