r - Как удалить горизонтальную линию между заголовком и телом в DT :: datatable - PullRequest
1 голос
/ 11 июня 2019

Я хочу убрать полосы в пределе между данными таблицы и заголовком или, по крайней мере, изменить его цвет.

Я хочу составить расписание для учителей с соответствующими классами.

                    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 Ответ

0 голосов
/ 11 июня 2019

С опцией 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'});","}")))
...