简体   繁体   English

DT R Shiny-添加标题边框

[英]DT R Shiny - Add header border

I would like to add a top border to the header of a DataTable output in a Shiny App so that it follows the format you'd see in a typical journal article. 我想在Shiny App中为DataTable输出的标题添加一个顶部边框,以便它遵循您在典型期刊文章中看到的格式。 Example of desired table format: desired format 所需表格格式的示例: 所需格式

Here is where I stand: 这就是我的立场:

 output$core_metrics <- renderDataTable(core_metrics(), rownames = F,
                                       options = list(
                                         dom = 't',
                                         class = 'compact',
                                         columnDefs = list(list(className = 'dt-center', targets = "_all")),
                                         initComplete = JS("function(settings, json) {$(this.api().table().header()).css({
                                                           'border-top' : '5px solid black'});}")

I am able to change other aspects of the header column, such as font size, but none of the border calls function. 我能够更改标题列的其他方面,如字体大小,但没有任何边框调用功能。 I know next to nothing about CSS and I expect that perhaps I need to change or add to the .header() part of the expression? 我对CSS几乎一无所知,我希望我可能需要更改或添加到表达式的.header()部分? Thank you for your time! 感谢您的时间!

library(DT)

headerCallback <- c(
  "function(thead, data, start, end, display){",
  "  $('th', thead).css('border-top', '5px solid black');",
  "}"
)

datatable(iris, rownames = FALSE, 
          options = list(
            headerCallback = JS(headerCallback)
          )
)

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM