2017-05-02 9 views
1

Great Rコミュニティ アクションボタンを押してモーダルでDT :: dataTableOutputを表示できるかどうかは疑問です。例えば、データテーブルは次のように出力されます。ここで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) 
+2

bsModel()は、shinyBSのパッケージからUIをトリックする必要があります。編集:サーバーでもモーダルを定義する必要がありますが、サーバーでrenderDataTable()を続けることができます。 –

+0

パーフェクト・ソリューションRyan、job done! –

答えて

0

おかげ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) 
関連する問題