Create rhandsontable after clicking on the value of another rhandsontable in a shiny app

I have a shiny app with 2 rhandsontables.

#ui.r
navbarPage(
  "Application",
  tabPanel("General",
           sidebarLayout(

             sidebarPanel(
              ),

             mainPanel(
               rHandsontableOutput("hot3"),
               br(),
               rHandsontableOutput("hot5")
             )
           )))
#server.r
library(shiny)

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

  output$hot3 <-renderRHandsontable({
    DF = data.frame(Sel. = rep(TRUE,2),
                    Label=paste("Test",as.integer(1:2)),
                    Marg=rep("Marg1",2),
                    Avail.=as.integer(rep.int(50,2)),
                    Sel =as.integer(rep.int(50,2)),
                    stringsAsFactors = FALSE)
    rhandsontable(DF,width =500,height = 400)
  })
    output$hot5 <-renderRHandsontable({
      DF = data.frame(
        Sel= rep(TRUE, 50),
        Id= 1:50,
        Label=paste("Item",as.integer(1:50)),
        Pf=as.integer(rep.int(0,50)),
        stringsAsFactors = FALSE)
      rhandsontable(DF,width =500,height = 400)
    })


}

What I want is when I click on the first table on the column "Test 1" to create a second table with as many rows as the number of column" Avail". That means,for example, that when I will change this number from 50 to 40 I will have a new table with 40 rows. Alternatively, if there is no ability to create the 2nd table after clicking on "Test 1" I would like at least to be able to change the number of rows of the 2nd table by changing the number of "Avail".

For reference, this question has also been posted to Stackoverflow:
https://stackoverflow.com/questions/51233123/create-new-rhandsontable-based-in-the-value-of-another-rhandsontable-in-a-shiny

To keep in mind, there is a policy on cross-posting: FAQ: Is it OK if I cross-post?
Please follow it. Thank you !

3 Likes