在 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/