更改R DT数据表中控件的颜色 [英] change colour of controls in R DT datatable

查看:84
本文介绍了更改R DT数据表中控件的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在R中,闪亮和数据表(DT)希望将控件文本的颜色更改为蓝色,因为它暗示可以在这里进行:

In R shiny and datatable (DT) would like to change the colour of the control text to blue, as it suggests it can be here:

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

,方法是将控制文本:的值调整为#0000ff ,这似乎会改变颜色分页按钮的文本以及网页上的搜索文本等都是蓝色的,但是对于具有 datatable 的闪亮应用程序,我想这样做。任何帮助将不胜感激。

by adjusting the Control text: value to #0000ff which seems to change the colour of the text for the pagination buttons to be blue as well as the search text etc on the webpage, but i would like this for a shiny app with a datatable that has been rendered. Any help would be much appreciated.

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

Please see below for the example where the text has not had its text colour changed to blue...

  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代码)

Here is an example (only included UI code)

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")
        )
    )

这篇关于更改R DT数据表中控件的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆