javascript - 更改 R DT 数据表中控件的颜色

标签 javascript r datatable shiny

在 R shiny 和 datatable (DT) 中,想将控件文本的颜色更改为蓝色,因为它表明它可以在这里:

https://datatables.net/manual/styling/theme-creator

通过将 Control text: 值调整为 #0000ff 这似乎将分页按钮的文本颜色以及搜索文本等更改为蓝色在网页上,但我想要一个 Shiny 的应用程序,其中包含一个已呈现的 datatable。任何帮助将不胜感激。

请参阅下面的示例,其中文本的文本颜色未更改为蓝色...

  library(DT)
  library(shiny)

  ui=shinyUI(

    fluidPage(
      tags$head(tags$style(HTML("table.dataTable.hover tbody tr:hover, table.dataTable.display tbody tr:hover {
                                background-color: #9c4242 !important;
                                } "))),
      DT::dataTableOutput("tt")
      )
    )

  server=shinyServer(function(input, output) {
    output$tt=DT::renderDataTable(
      DT:::datatable(
        head(iris, 50),rownames = FALSE,options = list(dom='ptl',
                                                       initComplete = JS(
                                                         "function(settings, json) {",
                                                         "$(this.api().table().header()).css({'background-color': '#000', 'color': '#fff'});",
                                                         "}")
        ),
        container = tags$table(
          class="compact",
          tags$thead(tags$tr(lapply(colnames(iris), tags$th)))
        )
      ) %>% formatStyle(columns=colnames(iris),color='white',background = 'black',target = 'row')
    )
  })


  shinyApp(ui=ui,server=server)

最佳答案

这是一个示例(仅包含 UI 代码)

ui=shinyUI(

    fluidPage(
        tags$head(tags$style(HTML("table.dataTable.hover tbody tr:hover, table.dataTable.display tbody tr:hover {
                                  background-color: #9c4242 !important;
                                  }
                                  "))),
        tags$style(HTML(".dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_processing,.dataTables_wrapper .dataTables_paginate .paginate_button, .dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
            color: #0000ff !important;
        }")),
      DT::dataTableOutput("tt")
        )
    )

关于javascript - 更改 R DT 数据表中控件的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37444317/

相关文章:

javascript - 欧拉计划 #5 Javascript

javascript - "Stop running this script"确认框 - 如何获取有关脚本的更多详细信息?

jquery - 如何使用 jQuery 对数据表按字母顺序排序且不区分大小写?

r - 将包含总计和百分比的行添加到 DT 数据表

javascript - 使行可点击(复选框除外)

javascript - 如何使用 select 过滤 Google Maps API v.3 中 json 数据中的两个属性?

javascript - 使用 RegExp 在模式中查找模式的多个实例

r - 在 R 中将函数迭代应用到它自己的结果

r - 塑造数据并影响 R 中的计数列

r - 我怎样才能让 R 的输出更详细,以便让我放心它还没有坏?