Great 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)
答案 0 :(得分:3)
感谢您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)