有光泽的:在第一次单击actionButton之后切换menuSubItems时没有响应

时间:2017-01-26 07:43:13

标签: shiny

通过使用shiny和shinydashboard包,我创建了一组menuItems和menuSubItems以及相应的tabItems,并且每个menuSubItems都有一个带有不同输入参数的conditionalPanel, 和一个用于不同分析和绘图任务的actionButton,现在它在单击actionButton之前工作,也就是说,在menuSubItems之间切换时,conditionalPanel会改变,并且它在第一次单击actionButton时效果也很好,也就是它显示了一个html的情节正如预期的那样,但是在第一次点击actionButton之后,在menuSubItems之间切换时,conditionalPanel不再像以前那样改变了,看来当用ui鼠标点击时,menuSubItems无法更新,我该如何解决?

程序太长了,我只能按如下方式粘贴它们: myshinyOutput是一个自定义函数,用于创建带有输入参数的html。

    server=function(input,output,session,dir="D:/ShinyServer"){
      observeEvent(input$sidebarmenu,{
        js$collapse("parbox")
        if(input$sidebarmenu=="a") {
          selmets=c("a"="a","b"="b")
          selstatistic=c("stat"="mean","statb"="anomaly")
          updateSelectInput(session,inputId="selmets",choices=selmets,selected=c("t","r","s"))
          updateSelectInput(session,inputId="selstatistic",label="sel:",choices=selstatistic,selected="mean")
          updateDateRangeInput(session,inputId="dateRange",start=inputdateRange$start,end=inputdateRange$end)
          updateSelectInput(session,inputId="selstationoption",selected="all")
          updateSelectInput(session,inputId="saveres",selected="plot")
          updateTextInput(session,inputId="compyear",value="")   
        }else if(input$sidebarmenu=="b") {
          selmets=c("sunshine","fog","haze","hail","snow","snowdepth")
          updateSelectInput(session,inputId="selmets",choices=selmets,selected=c("sunshine"))
          updateDateRangeInput(session,inputId="dateRange",start=inputdateRange$start,end=inputdateRange$end)
          updateSelectInput(session,inputId="saveres",selected="plot")
        }     
      })

      htmlvalues=reactive({
        if(input$runButton == 0)
        {
          return()
        }
       #isolate({
          input$runButton
          renderUI({isolate(myshinyOutput(input,rootdir=dir,htmlwidth=2000)$html)})
       #})
      })


      downloadlisthtml=reactive({
        if(input$runButton == 0)
        {
          return()
        }
       #isolate({
          input$runButton
          renderUI({isolate(gendownloadlisthtml())})
       #})
      })  

      observeEvent(input$runButton,
                   {
                     js$collapse("parbox")
                     if(input$sidebarmenu=='grd'){

                     }else{
                       output[[paste(shinymodulesub(input$sidebarmenu),"_html",sep="")]]=htmlvalues()
                       output[[paste(shinymodulesub(input$sidebarmenu),"download_html",sep="")]]=downloadlisthtml()
                     }    
                   })
    }


    # > sessionInfo()
    # R version 3.3.2 (2016-10-31)
    # Platform: i386-w64-mingw32/i386 (32-bit)
    # Running under: Windows 7 (build 7600)
    # 
    # 
    # other attached packages:
    #   [1] shinydashboard_0.5.3
    # [2] shiny_1.0.0         
    # 
    # loaded via a namespace (and not attached):
    #   [1] R6_2.1.1        htmltools_0.3.5
    # [3] tools_3.3.2     Rcpp_0.12.9    
    # [5] digest_0.6.8    xtable_1.7-4   
    # [7] httpuv_1.3.3    mime_0.3

0 个答案:

没有答案