I have a question about Shiny.
If you put in search criteria and get the result, I want to switch tab to the table in the data display and display it.
However, the updateTabsetPanel does not work.
Please let me know if there is a problem.
Server.R to
shinyServer(function(input,output){
callModule(tab_search, id="tab_search")
})
This is the module that was created.
################################################################################
#the layout for tab search item
#Parameter: p_shipment
# p_product
tab_searchUI <- function(id, tab_name,p_shipment,p_product,p_duration) {
ns <- NS(id)
tabItem(tabName = tab_name,
sidebarLayout(
sidebarPanel(
#Set the search condition here.
#The first search key is duration.
dateRangeInput(inputId = ns("i_dates"), label = "Duration"),
#The second search key is shipments
selectizeInput(
inputId = ns("i_shipment"), label = "Shipment", choices = state.name, multiple = TRUE
),
#The third search key is data products
selectInput(
inputId=ns("i_product"), label="Product", choices=state.name, multiple=TRUE
),
# The search button
actionButton(inputId=ns("b_srh"), label="Search")
),
# Output the search result.
mainPanel(
tabsetPanel(type="tabs",
id=ns("srh_tabs"),
tabPanel("Search",
h2("Search result is show here.", align="center"),
br(),
div(img(src="bigorb.png"), align="center") ,
tabPanel("Table", tableOutput(ns("table")),
tabPanel("Summary", verbbatimTextOutput(ns("summary")),
tabPanel("Plot",plotOutput(ns("Plot"))
)
)
)
)
}
################################################################################
# Server side corresponding the tab of tab_searchUI
# Notice the function name is pending with corresponding UI
#
tab_search<-function(input, output, session){
srhresult<-NULL
ltabs<- NULL
stub<-NULL
# The case to use event reactive function for getting the event of a button.
reactive_data<- eventReactive(input$b_srh,{
# Set the search result
ltabs<-session$ns("srh_tabs")
stub<-session$ns("table")
print( paste("tabset name is",ltabs,">>")
print(paste("tab name is",stab,">>")
g_Search_rlt <<-srhresult
srhresult<-pistonrings
})
output $table<-renderTable(reactive_data())
# Change the tab to table
observeEvent(input$b_srh, {
print(session$ns("srh_tabs"))
print(session$ns("table"))
updateTabsetPanel(session, paste(session$ns("srh_tabs")),
selected = paste(session$ns("table"))
)
# output$caption<-renderText(paste(l_caption(), "case2"))
})
}
First, if you use updateTabsetPanel
, you must specify value
for tabset
.
tabPanel("Table", tableOutput(ns("table")), value=ns("table"))
Then, if you are using a ShinyModule, you must pass the correct session
.
In this case, the parent session
.
tab_search<-function(input, output, session, parentSession) {#edit
# (Omitted)
# Change the tab to table
observeEvent(input$b_srh, {
updateTabsetPanel(parentSession, session$ns("srh_tabs"), #edit
selected = session $ns("table")
)
})
}
server<-function(input, output, session){
callModule(tab_search, id="tab_search", session)#edit
}
891 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
568 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
611 Uncaught (inpromise) Error on Electron: An object could not be cloned
601 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.