【问题标题】:R datatable: Hide search box for individual columnsR数据表:隐藏各个列的搜索框
【发布时间】:2016-02-21 04:37:55
【问题描述】:

我想启用按列搜索,但对特定列禁用它。

这几乎是我需要的 https://rstudio.github.io/DT/009-searchable.html 但我想隐藏未使用的盒子。

有什么办法吗?

【问题讨论】:

    标签: r shiny dt


    【解决方案1】:

    您在search 类型的禁用输入上使用带有选择器的 CSS 来隐藏它们。

    以下是闪亮应用中的示例:

    library(shiny)
    
    shinyApp(
    
      ui = fluidPage(tags$head(tags$style(
        HTML("input[type='search']:disabled {visibility:hidden}")
      )),
      DT::dataTableOutput('tbl')),
    
      server = function(input, output) {
        iris2 = head(iris, 10)
        output$tbl = DT::renderDataTable(datatable(
          iris2,
          filter = 'top',
          options = list(columnDefs = list(list(
            targets = c(1, 3), searchable = FALSE
          )),
          pageLength = 5)
        ))
      }
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-03
      • 2012-10-28
      • 1970-01-01
      • 1970-01-01
      • 2022-11-24
      • 1970-01-01
      • 2019-02-03
      • 2016-01-19
      相关资源
      最近更新 更多