I have a problem with convert my shiny app to use Shiny Modules. In my app I have a ConditionalPanel where conditional is a js-string to DT:datatable_rows_selected. I don't understand how I need to rewrite this condition to work with ShinyModule conception.
Example: This is work correct (when select rows in table - ConditionalPanel is open):
library(shiny) library(DT) shinyApp( ui = fluidPage( DT::dataTableOutput("testTable"), conditionalPanel(condition = "typeof input.testTable_rows_selected !== 'undefined' && input.testTable_rows_selected.length > 0", verbatimTextOutput("two") ) ), server = function(input,output) { output$testTable <- DT::renderDataTable(mtcars, selection=list(mode="multiple",target="row")) output$two <- renderPrint(input$testTable_rows_selected) } )
But this is not work:
library(shiny)
library(DT)
testUI <- function(id) {
ns <- NS(id)
table_id = ns("testTable")
tagList(
DT::dataTableOutput(table_id),
conditionalPanel(condition = paste0("typeof input.",table_id,"_rows_selected !== 'undefined' && input.",table_id,"_rows_selected.length > 0"),
verbatimTextOutput(ns("two"))
)
)
}test <- function(input,output,session) {
ns <- session$ns
output$testTable <- DT::renderDataTable(mtcars, selection=list(mode="multiple",target="row"))
output$two <- renderPrint(input$testTable_rows_selected)
}shinyApp(
ui = testUI("one"),
server = function(input,output) {
out <- callModule(test,"one")
}
)