【发布时间】:2020-06-23 13:32:26
【问题描述】:
我开发了一个具有不同模块和文件的闪亮应用程序,但我的 updateTabsetPanel 存在一些问题: 一个主文件,其中每个选项卡项都是不同文件中的不同模块。 我让模块 explore 和 annotate 像这样调用:
#### in the main app
server <- function(input,output,session){
ns <- session$ns
## Sidebar panel for inputs
output$menu <- renderMenu({
sidebarMenu(id = "tabs_menu",
menuItem("Input data",tabName ="datafile", icon = icon("file-import")),
menuItem("Explore", tabName = "explore", icon = icon("microscope")),
menuItem("Annotate", tabName = "annotate", icon = icon("edit")),
menuItem("Clusters", tabName = "cluster", icon = icon("asterisk"))
)})
global_data <- callModule(Module_input_data_server, "data_module" )
#Module explore
observeEvent(input$tabs_menu,{
if(input$tabs_menu=="explore"){
callModule(Module_explore_server, "explore_module", global_data )
}
}, ignoreNULL = TRUE, ignoreInit = TRUE)
#Module annotate
observeEvent(input$tabs_menu,{
if(input$tabs_menu=="annotate"){
callModule(Module_annotate_server, "annotate_module",global_data)
}
}, ignoreNULL = TRUE, ignoreInit = TRUE)
}
在探索模块中,我有不同的模块,其中一个是我想在单击按钮后通过模块注释返回的表格。所以目标是点击动作按钮后返回探索。但它不起作用。
#### in the annotate module the observe event for the click button
Module_annotate_server <- function(input, output,session, rv) {
req(rv$data)
ns <- session$ns
observeEvent(input$annotateButton,{
req(rv$data)
print("how")
# if(is.null(rv$secure)){
if(!is.null(input$newCol) && input$newCol != "") {
print("how1")
new.column <- rep(NA,nrow(rv$data))
rv$data <- cbind(rv$data, new.column)
colnames(rv$data)[ncol(rv$data)] <- input$newCol
rv$annotationCol <- input$newCol
} else if(!is.null(input$annotationCol) && input$annotationCol != "") {
print("how2")
rv$annotationLabels <- unique(rv$data[,input$annotationCol])
rv$annotationCol <- input$annotationCol
}
if(length(input$labelsList)>0) {
print("how3")
new.labels <- unlist(strsplit(input$labelsList, "\\s*,\\s*"))
if(length(new.labels)>0) {
rv$annotationLabels <- c(input$annotationLabels, new.labels)
}
}
if(is.null(rv$annotationLabels) || length(rv$annotationLabels) == 0) {
showNotification("Some labels must be provided.", type ="error", duration = NULL)
} else {
# Move to the Explore tab
updateTabsetPanel(session , "tabs_menu", selected = "explore")
}
}
如果您有想法,我想知道问题可能是会话或其他问题。
谢谢!
【问题讨论】: