R数据表:隐藏各个列的搜索框 [英] R datatable: Hide search box for individual columns

查看:121
本文介绍了R数据表:隐藏各个列的搜索框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would like to enable searching by columns but disable it for particular columns.

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

Here is almost what I need https://rstudio.github.io/DT/009-searchable.html but I would like to hide the unused boxes.

有什么方法吗?

推荐答案

您将CSS与选择器结合使用,将选择器放在 search 类型的隐藏输入中。

You use CSS with a selector on the disabled inputs of type search to hide them.

闪亮应用程序中的示例:

Here's an example in a shiny app:

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)
    ))
  }
)

这篇关于R数据表:隐藏各个列的搜索框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆