簡體   English   中英

在閃亮的app中以模態顯示dataTableOutput

[英]Show dataTableOutput in modal in shiny app

偉大的R社區,我只是想知道是否可以通過按下操作按鈕在模式中顯示DT :: dataTableOutput。 例如,數據表輸出如下所示。

在此輸入圖像描述

以下是一些代碼:

## app.R ##
library(shiny)
library(shinydashboard)

ui <- dashboardPage(

  dashboardHeader(),
  ## Sidebar content
  dashboardSidebar(
    sidebarMenu(
      menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"))
    )
  ),

  ## Body content
  dashboardBody(
    tabItems(
      # First tab content
      tabItem(tabName = "dashboard",
              actionButton("showTable", "Show Table", icon = icon("table"))
              ##fluidRow( DT::dataTableOutput('tbl') )
              ## SOME CODE TO SHOW DATA TABLE IN MODAL
      )
    )
  )
)

server <- function(input, output) { 
  output$tbl = DT::renderDataTable(
    iris, options = list(lengthChange = FALSE) 
  )
}

shinyApp(ui, server)

感謝Ryan的快速建議。 得到它釘。 這是我的工作示例:

## app.R ##
library(shiny)
library(shinyBS)
library(shinydashboard)

ui <- dashboardPage(

  dashboardHeader(),
  ## Sidebar content
  dashboardSidebar(
    sidebarMenu(
      menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"))
    )
  ),

  ## Body content
  dashboardBody(
    tabItems(
      # First tab content
      tabItem(tabName = "dashboard",
              actionButton("showTable", "Show Table", icon = icon("table")),
              bsModal("modalExample", "Data Table", "showTable", size = "large",
                      dataTableOutput("tbl"))
      )
    )
  )
)

server <- function(input, output) { 
  output$tbl = renderDataTable( iris, options = list(lengthChange = FALSE))
}

shinyApp(ui, server)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM