can not see my second tabitem after clicking action button
sgr308 opened this issue · comments
Sagar Patel commented
Hi
I am learning Shiny to develop an App.
I have two tabItems in sidebar where first one is simple home page and in another, user has to upload the .txt file.
After click on submit button I want to see the uploaded file contents but I can not see the second tabitem contents in my dashboardBody after clicking on action button.
Can someone please let me know if I am missing something in this code??
The code is here:
# Upload library ----
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "First App"),
dashboardSidebar(
sidebarMenu(
id = "tabs",
menuItem("About", tabName = "first", icon = icon("home")),
menuItem("Upload Data", tabName = "second", icon = icon("home"),
fileInput("file1", "Upload a .txt file",
accept = c("text/csv", "text/comma-separated-values,text/plain",".csv",
options(shiny.maxRequestSize=900*1024^2))),
actionButton('submit', 'Submit!!'))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "first",
h3("App Ver 0.1.0")
),
tabItem(tabName = "second",
h2("Results Table"),
tableOutput("contents")
)
)
)
)
server <- function(input, output, session) {
observeEvent(input$submit, {
updateTabItems(session, "tabs", selected = "first" )
})
output$contents <- renderTable(rownames = TRUE,{
if (is.null(input$file1)) return(NULL)
head(read.csv(input$file1$datapath))
})
}
shinyApp(ui, server)
ismirsehregal commented
For future readers: here you can find a workaround.