How do I change the highlight color for the sorted column(s) in R Shiny?
How do I change the highlight color for the sorted column(s) in R Shiny?
Hi, I am new to DT and would like some help changing the sort highlight color in R Shiny.
I have the "ordering" and "orderMulti" set to TRUE. The default highlight color on the sorted column(s) is very light and I would like to know how to change it. Using the online example, I was able to change the header color for the table. I tried (and failed!) a similar method to edit the color for sorting_1.
Below is my R code. If packages "shiny" "DT" and "data.table" are installed, this code should run the app in R.
library(shiny)
library(DT)
library(data.table)
server <- function(input, output) {
output$test_table <- DT::renderDataTable({
mydata <- mtcars
as.data.table(mydata)
},
filter= list(position='top', clear=FALSE),
options = list(dom='<"wrapper"ftlip>', orderClasses = TRUE, orderMulti=TRUE,
ordering=TRUE,
searchHighlight = TRUE,
search = list(regex = TRUE, caseInsensitive = TRUE),
initComplete = JS(
"function(settings, json) {",
"$(this.api().table().header()).css({'background-color': '#ff0000', 'color': '#000'});",
"$(this.api().column().sorting_1()).css({'background-color': '#ff0000', 'color': '#000'});",
"}")
)
)
}
ui <- shinyUI(fluidPage(
DT::dataTableOutput("test_table")
))
shinyApp(ui = ui, server = server)
Thank you in advance for your time!