我想删除表格数据和标题之间的限制,至少要更改其颜色。
我想为老师安排各自教室的时间表。
options = (list(pageLength = 40,
dom = 't',
ordering = FALSE,
columnDefs = list(list(className = 'dt-center', targets = 0:5)),
initComplete = JS("function(settings, json) {",
"$(this.api().table().header()).css({'background-color': '#3b5998', 'color': '#ffffff', 'border-right': '1px solid #ffffff'});","}"))
)) %>% formatStyle(names(Profesor),
border = '1px solid #ffffff',
fontSize = '15px',
color = '#f7f7f7',
backgroundColor = styleEqual(c(NA, valores), c('#f7f7f7', rep('#8b9dc3',length(valores)))),
borderCollapse = TRUE
) %>%
formatStyle(columns = ' ',
backgroundColor = '#3b5998',
borderBottomColor = "#ffffff",
borderBottomStyle = "solid",
borderBottomWidth = "1px",
color = '#ffffff',
fontSize = "15px",
fontWeight = "bold",)
})```
[1]: https://i.stack.imgur.com/eMb9n.png
答案 0 :(得分:0)
使用headerCallback
选项:
headerCallback <- c(
"function(thead, data, start, end, display){",
" $('th', thead).css('border-bottom', 'none');",
"}"
)
datatable(iris,
options =
list(pageLength = 40,
dom = 't',
ordering = FALSE,
headerCallback = JS(headerCallback),
columnDefs = list(list(className = 'dt-center', targets = 0:5)),
initComplete = JS("function(settings, json) {",
"$(this.api().table().header()).css({'background-color': '#3b5998', 'color': '#ffffff', 'border-right': '1px solid #ffffff'});","}")))