R Shiny DataTable selected row color

前端 未结 1 1819
刺人心
刺人心 2020-12-06 03:28

I am trying to set the highlight color for a selected row in a DataTable in my shiny app. Basically I want the color of selected rows to be say red rather than blue. However

相关标签:
1条回答
  • 2020-12-06 04:08

    This should do the job:

    #rm(list = ls())
    library(shiny)
    library(DT)
    
    ui <- basicPage(
      tags$style(HTML('table.dataTable tr.selected td, table.dataTable td.selected {background-color: pink !important;}')),
      mainPanel(DT::dataTableOutput('mytable'))
    )
    
    server <- function(input, output,session) {
    
      output$mytable = DT::renderDataTable(    
        datatable(mtcars)
      ) 
    }
    runApp(list(ui = ui, server = server))
    

    0 讨论(0)
提交回复
热议问题