gpt4 book ai didi

r - 在 Shiny 的应用程序中以模态显示 dataTableOutput

转载 作者:行者123 更新时间:2023-12-04 09:28:02 24 4
gpt4 key购买 nike

伟大的 R 社区,
我只是想知道是否可以通过按下操作按钮在模式中显示 DT::dataTableOutput。例如,数据表输出如下。

enter image description here

下面是一些代码:

## 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)

关于r - 在 Shiny 的应用程序中以模态显示 dataTableOutput,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43748316/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com