在闪亮的应用程序中以模式显示dataTableOutput [英] Show dataTableOutput in modal in shiny app

查看:146
本文介绍了在闪亮的应用程序中以模式显示dataTableOutput的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Great R community, I am just wondering if it is possible to show DT::dataTableOutput in a modal with the push of an action button. For example, data table output as something like following.

这是一些以以下代码开头的代码:

Here is a some code to begin with:

## 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 的快速建议。钉牢。这是我的工作示例:

Thanks Ryan for your quick suggestion. Get it nailed. Here is my working example:

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

这篇关于在闪亮的应用程序中以模式显示dataTableOutput的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆