Is there a way to display different values in a dropdown filter for a factor column in a DataTable? I would like to have HTML rendering within the column, but show a different label when filtering. I tried using factor labels without success. I plan to use this table in a Shiny app and am open to using CSS or JS modifications to achieve this.
In this example, the text in the table is bolded - ideally, only the values themselves should appear in the filtering dropdown, without the HTML tags. Is there a solution for this?
library(dplyr)
DT::datatable(
iris %>%
mutate(Species = factor(Species, levels = unique(.$Species),
labels = paste0('<strong>', unique(.$Species), '</strong>'))),
escape = FALSE,
filter = 'top')
Here's an image showcasing the desired outcome - removing the HTML tags from the filter options: https://i.sstatic.net/V04DWEVt.png