如何在闪亮的数据表中更改列过滤器控件

时间:2021-07-28 13:02:36

The documentation for the R shiny DataTables package (https://rstudio.github.io/DT/ see section 2.8) says this about column filters:

R闪亮数据包的文档(https://rstudio.github)。io/DT/ see section 2.8关于列过滤器:

Depending on the type of a column, the filter control can be different. Initially, you see search boxes for all columns. When you click the search boxes, you may see different controls:

根据列的类型,过滤器控件可以是不同的。最初,您会看到所有列的搜索框。当你点击搜索框时,你可能会看到不同的控件:

For numeric/date/time columns, range sliders are used to filter rows within ranges;

对于数字/日期/时间列,范围滑块用于筛选范围内的行;

For factor columns, selectize inputs are used to display all possible categories, and you can select multiple categories there (note you can also type in the box to search in all categories);

对于因子列,选择输入用于显示所有可能的类别,您可以在其中选择多个类别(注意,您也可以在框中输入以搜索所有类别);

For character columns, ordinary search boxes are used to match the values you typed in the boxes;

对于字符列,一般的搜索框用于匹配您在框中键入的值;

Does DataTables have a way to change this? I have numeric columns but I'd like to filter them using an ordinary search box, not the range sliders.

DataTables有办法改变这一点吗?我有数字列,但是我想使用普通的搜索框来过滤它们,而不是使用范围滑块。

1 个解决方案

#1


2  

I honestly don't thik there is much you can do if the DT package doesn't support this feature. You could either

老实说,我认为如果DT包不支持这个特性,您可以做很多事情。你可以

  1. Change the column type from numeric to an ordered factor (dat$col <- factor(dat$col, ordered = TRUE))
  2. 将列类型从数字更改为有序因子(dat$col <- factor, dat$col, ordered = TRUE))
  3. Submit an issue/PR to the github repo and ask/implement an extension for the filtering interface.
  4. 向github repo提交问题/PR并请求/实现过滤接口的扩展。
  5. Implement your own filtering UI based on this article.
  6. 基于本文实现您自己的筛选UI。

Maybe take a look at this function to get a better idea how to implement option 3.

也许可以看看这个函数,了解一下如何实现选项3。

#1


2  

I honestly don't thik there is much you can do if the DT package doesn't support this feature. You could either

老实说,我认为如果DT包不支持这个特性,您可以做很多事情。你可以

  1. Change the column type from numeric to an ordered factor (dat$col <- factor(dat$col, ordered = TRUE))
  2. 将列类型从数字更改为有序因子(dat$col <- factor, dat$col, ordered = TRUE))
  3. Submit an issue/PR to the github repo and ask/implement an extension for the filtering interface.
  4. 向github repo提交问题/PR并请求/实现过滤接口的扩展。
  5. Implement your own filtering UI based on this article.
  6. 基于本文实现您自己的筛选UI。

Maybe take a look at this function to get a better idea how to implement option 3.

也许可以看看这个函数,了解一下如何实现选项3。