Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Inconsistent behavior during cell selection in DT datatable

$
0
0

I have the shiny app below in which the user clicks on a cell in the upper table and the relative cell should be displayed in the lower table. The issue is that when I unselect the cells in the upper the cells in the lower not only remain but become more.

library(shiny)
library(DT)
data("mtcars")

ui <- shinyUI(
  fluidRow(
    DT::dataTableOutput("myDatatable"),
    DT::dataTableOutput("myDatatable2")

  )

)

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


  dat1 <- reactive({
    matrix(iris[,5])
  })


  list_all <- reactiveVal(character())
  observeEvent(input$myDatatable_cell_clicked, {
    list_all(append(list_all(), input$myDatatable_cell_clicked$value))
  })



  output$myDatatable <- DT::renderDataTable(dat1(), 
                                            selection=list( target="cell"),
                                            server = FALSE,
                                            rownames=FALSE)
  output$myDatatable2 <- DT::renderDataTable(matrix(list_all()), 
                                             selection="none",
                                             server = FALSE,
                                             rownames=FALSE)

})

shinyApp(ui, server)

Viewing all articles
Browse latest Browse all 201839

Trending Articles