r语言 - 如何在 DT::d atatable 中删除标头和正文之间的水平线



我想删除 de table 数据和标题之间的条纹限制,或者至少更改其颜色。

我想为老师们制定一个时间表,让他们有各自的教室。

                    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

使用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'});","}")))