问题
I want to remove the stripes in te limit between de table data and the header, or at least, change its color.
I want to make an schedule for teachers with their respective classroom.
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
回答1:
With the headerCallback
option:
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'});","}")))
来源:https://stackoverflow.com/questions/56533474/r-how-to-remove-the-horizontal-line-between-the-header-and-the-body-in-a-dtd