【问题标题】:r - How to remove the horizontal line between the header and the body in a DT::datatabler - 如何删除 DT::datatable 中标题和正文之间的水平线
【发布时间】:2019-10-25 06:32:05
【问题描述】:

我想去除de表数据和表头之间的限制条纹,或者至少改变它的颜色。

我想为各自教室的教师制定时间表。

                    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

【问题讨论】:

    标签: r shiny datatables dt


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2020-12-26
      • 1970-01-01
      • 2019-02-24
      • 1970-01-01
      • 2020-10-22
      • 2022-11-03
      • 2021-08-27
      • 1970-01-01
      • 2019-03-03
      相关资源
      最近更新 更多