基于pickerinput选择的闪亮更新表内容

问题描述

这是我第一次使用光泽。我建立了一个数据库来提供现有的应用程序。我创建的新模块(通过修改一个by_country页面太复杂了),无法正常工作。

正在显示表“ tablepreped.xlsx”,下拉菜单也在显示中,但是当我更改选择器时,表的过滤没有更新。

基本上,我想选择一个指标,然后根据该指标在我的表格中过滤国家/地区名称,差距大小和差距值,理想情况下还可以选择差距大小。如果有人能指出正确的方向,我将不胜感激!

server <- function(input,output,session) {

  observeEvent(input$go_to_aimm_landing,{

    hideElement("main_app")
    showElement("landing_page")

  })

  observeEvent(landing_page_return$page_selected_trigger(),{

    page_ <- landing_page_return$page_selected()

    updateNavbarPage(
      session,"nav_pages",selected = page_
    )

  landing_page_return <- callModule(
    landing_page_module,"landing_page_id"
  )

  by_country_return <- callModule(
    by_country_module,'by_country',indicator_dat = dat,rank_ranges = band_ranges,defaults = landing_page_return$default_selected
  )

  callModule(
    by_size_module,'by_size'
  )

  callModule(
    map_module,'map_id',default_selected = landing_page_return$default_selected
  )
}

服务器

by_size_module_ui <- function(id) {
  ns <- NS(id)

  tabsetPanel(
    tabPanel(
      "Indicators",fluidRow(
        br(),column(
          width = 10,fluidRow(
            column(
              width = 12,tagList(
                fluidRow(
                  column(
                    width = 2,pickerInput(
                      ns("country"),"Country",choices = choices$country,selected = "Tanzania",options = list(
                        'live-search' = TRUE,'live-search-placeholder' = 'Search...','live-search-normalize' = TRUE,'live-search-style' = 'contains'
                      ),width = "100%"
                    )
                  ),column(
                    width = 4,pickerInput(
                      ns("indicator_names"),"Indicator",choices = choices$indicator_names,selected = "Adult account holders",column(
                    width = 2,pickerInput(
                      ns("indicator_type"),"Type of Indicator",choices = choices$indicator_type,choicesOpt = list(
                        disabled = c("gap","intensity") %in% c("intensity")
                      ),selected = "gap",multiple = TRUE,options = pickerOptions(
                        actionsBox = TRUE,liveSearch = TRUE,liveSearchPlaceholder = 'Search...',liveSearchNormalize = TRUE,liveSearchStyle = 'contains'
                      ),pickerInput(
                      ns("gap_size"),"Gap Size",choices = choices$gap_size,selected = "l",width = "100%"
                    )
                  )
                )
              )
            ),column(
              width = 12,h2(
                style = "margin-left: 5px; margin-top: 25px; white-space: nowrap;","Indicator: ",textOutput(ns("sel_indicator_name"),inline = TRUE)
              )
            )
          )
        )
      ),tagList(DTOutput(ns("by_size_table")) %>%
          withSpinner(),tags$script(src = "by_country_time_series.js"),tags$script(paste0("by_country_module_js('",ns(''),"')"))
      ),br(),br()
    )
  )
}

by_size_module <- function(input,session,tablepreped,default_selected) {
  ns <- session$ns

  default_selected <- reactive({

    list(
      default_indicator_name = input$indicator_names,default_country = input$country,default_gap_size = input$gap_size,default_indicator_type = input$indicator_type
    )

  })


  ### GAP Ranges table ----------
  library('datasets')
  library("openxlsx")
  tablepreped <- read.xlsx("tablepreped.xlsx")

##Makes title reactive to indicator input
  indoc <- reactive({
    sel_indicator_name <- input$indicator_names

  })

  output$sel_indicator_name <- renderText({
    indoc()
  })


  # filter data for the selected indicator and gap size
  tablepreped_filtered <- reactive({
    gsize<-input$gap_size

    hold<-input$indicator_names

    hold_gap_size <- hold %>%
      dplyr::filter(gap_size == gsize)

    ctry_indicator_values <- hold_gap_size %>%
      select(country,gap_vals,gap_size)


  })

  # create data frame

    out <- tablepreped

    out<-out %>%
        select(
        country,indicator_name,gap_size
      )

  output$by_size_table <- DT::renderDataTable({
    DT::datatable(out,rownames = FALSE,class = "compact stripe",options = list(orderClasses = TRUE)
                  )
  })
}

这是数据帧头

structure(list(country = c("Afghanistan","Afghanistan","Afghanistan"),code = c("gap_ind_0001","gap_ind_0002","gap_ind_0003","gap_ind_0005","gap_ind_0006","gap_ind_0007"),indicator_name = c("Affordability ","Infrastructure","Poverty Rate","Adjusted years of schooling","Adult literacy","Account holders,female"),s = c(70,60,67,8,58.2,55),m = c(60,45,50,7,39.5,34.9),l = c(45,30,5,26,21.5),gap_size = c("vl","l","m","vl","s","vl"),gap_vals = c(29.58082,23.3432,18.330012,4.87,14.893313,7.160684)),row.names = c(NA,6L),class = "data.frame")

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...