Hi All,
I am creating Dash board with several reports . I am using dropdown in individual Tabpanels. When i click on Table 1 the caption above the report should be displayed Table 1.If I am clicking on Table 2 the caption above should be Table 2. As of now in the below code in the output settings I am able to set the buttons . Caption is displaying only what I mentioned there. So for both reports it is displaying "Table 1Report".
Please help me on fixing this issue. Thank You.
library(shinydashboard)
library(shiny) # Shiny web app
library(DT) # for data tables
library(shinyWidgets)
library(leaflet)
library(DBI)
library(dplyr)
library(readxl)
ui <- dashboardPage(
dashboardHeader(disable = TRUE),
dashboardSidebar(disable = TRUE),
dashboardBody(
fluidPage(
tags$div(align = "center",style = "color:#3090C7;font-size: 50px;","MY TEST DASHBOARD"),
tags$style(HTML("
.tabbable > .nav > li > a {background-color:#728FCE; color:black; width: 200PX;} ")),
tabsetPanel(tabPanel("About",
fluidRow(h3("About data",style = "color:#3090C7")),
),
navbarMenu("Data tab ",
tabPanel("SUB FOLDER",
br(),
tabsetPanel(
tabPanel("TAB 1",
br(),
tags$div(style = "color:#728FCE;font-size: 17px;",selectInput("Test", "Select Report",choices = c("Table 1","Table 2"))),
sidebarLayout(
sidebarPanel(width=3,
checkboxGroupInput("col_TT","Columns to display:",choices = c())
),
mainPanel(
DT::dataTableOutput("Test_data"))
)
)# outside tabpanel
)# TABSET pANEL ENDS HERE
)# TABPANEL BIRTHS ENDS
)#NAVBAR DROP DOWN ENDS HERE
)
)
)
)
server <- function(input, output,session) {
TT <- reactive ({
switch(input$Test,
"Table 1" = data.frame(read_excel('Table1.xlsx')),
"Table 2" = data.frame(read_excel('Table2.xlsx'))
)
})
observeEvent(input$Test,{
req(TT()) # we need df()
#update input$col_n with colnames of selected dataset
updateCheckboxGroupInput(
session,
"col_TT",
choices = colnames(TT()),
selected = colnames(TT())
)
})
output$Test_data <- DT::renderDataTable({
req(all(input$col_TT %in% names(TT())))
DT::datatable(
TT() %>% select_at(input$col_TT),
rownames = FALSE,
caption = "Tabel 1 Report ",
editable = TRUE,
extensions = 'Buttons',
filter = list(position = "top",clear = FALSE, plain = FALSE),
options = list(
lengthMenu = c(30, 50),
pageLength = nrow(TT()),
scrollY =1600, scroller = TRUE, scrollX = T,
paging = TRUE,
searching = TRUE,
fixedColumns = TRUE,
autoWidth = TRUE,
ordering = TRUE,
dom = 'Bfrtip',#IF tB displays only few values
buttons = c('copy', 'csv', 'excel','print'),
modifier = list(page = "current")),
class = "display nowrap compact" # style
)
})
}
# # run the app
shinyApp(ui, server)