Reputation: 43
The documentation for the R shiny DataTables package (https://rstudio.github.io/DT/ see section 2.8) says this about column filters:
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.
Upvotes: 4
Views: 2248
Reputation: 255
Unfortunately there is no way to be able to control this feature for now. You can change all the columns to factor :
renderedTable <- reactive({
data.frame(lapply(df,as.factor))
})
In this way you still be able to choose and search multiple options of numbers but the object are serialized as JSON array without slider.
Upvotes: 0
Reputation: 7695
I honestly don't thik there is much you can do if the DT
package doesn't support this feature. You could either
dat$col <- factor(dat$col, ordered = TRUE)
)Maybe take a look at this function to get a better idea how to implement option 3.
Upvotes: 2