admin管理员组文章数量:1327945
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:
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="pact",
tags$thead(tags$tr(lapply(colnames(iris), tags$th)))
)
) %>% formatStyle(columns=colnames(iris),color='white',background = 'black',target = 'row')
)
})
shinyApp(ui=ui,server=server)
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/manual/styling/theme-creator
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="pact",
tags$thead(tags$tr(lapply(colnames(iris), tags$th)))
)
) %>% formatStyle(columns=colnames(iris),color='white',background = 'black',target = 'row')
)
})
shinyApp(ui=ui,server=server)
Share
Improve this question
edited Nov 19, 2024 at 20:56
Jan
9,5136 gold badges20 silver badges33 bronze badges
asked May 25, 2016 at 17:47
h.l.mh.l.m
13.5k22 gold badges90 silver badges173 bronze badges
2
-
You just need to apply some CSS. If you inspect the page you linked, it changes the following elements
.dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_processing, .dataTables_wrapper .dataTables_paginate
– Xiongbing Jin Commented May 25, 2016 at 18:31 - 1 can you show me an example? – h.l.m Commented May 25, 2016 at 19:43
1 Answer
Reset to default 8Here 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")
)
)
本文标签: javascriptchange colour of controls in R DT datatableStack Overflow
版权声明:本文标题:javascript - change colour of controls in R DT datatable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742222663a2435551.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论