【问题标题】:R DT:datatable remove .no-footer border-bottomR DT:数据表删除 .no-footer 边框底部
【发布时间】:2020-02-26 01:58:14
【问题描述】:

尝试从 R 中的 DT:datatable 中删除页脚边框。

看着这个datatable,我发现下面的代码可以消除列名(为空的“”)和数据之间的边界(用红色表示):

  headerCallback <- c(
    "function(thead, data, start, end, display){",
    "  $('th', thead).css('border-bottom', 'none');",
    "}"
  ),
DT::datatable(
      data = myData(),
      class = "compact",
      rownames = FALSE,
      colnames = c("",""),
      caption = tags$caption(myTitle, style = "color:black"),
      options = list(
        dom = 't',
        ordering = FALSE,
        paging = FALSE,
        searching = FALSE,
        headerCallback = JS(headerCallback)
      )
    )

  })

我现在要做的是消除图像中底部的黑线。我发现以下链接似乎是我正在寻找的内容,但现在确定如何将它们合并到我所拥有的内容中:

r - How to remove the horizontal line between the header and the body in a DT::datatable

How To Remove Black Lines

当我检查网页上的元素并展开&lt;table&gt; 时,我可以取消选中this box,它会删除底部的黑线并给我想要的东西。但是,不确定如何将其写入我现有的或新的回调函数中。

【问题讨论】:

    标签: javascript css r shiny dt


    【解决方案1】:

    你可以这样做:

    datatable(
      data = iris[1:5,1:2],
      class = "compact",
      rownames = FALSE,
      colnames = c("",""),
      callback = JS("$('table.dataTable.no-footer').css('border-bottom', 'none');"),
      options = list(
        dom = 't',
        ordering = FALSE,
        paging = FALSE,
        searching = FALSE,
        headerCallback = JS(headerCallback)
      )
    )
    

    【讨论】:

    • 效果很好!所以如果我想在同一行添加table.dataTable thead td,我该怎么做?
    • @Mr.Norris 你能试试JS("$('table.dataTable.no-footer,table.dataTable thead td').css('border-bottom', 'none');")
    • 太棒了!是的,这也很有效。我确实将td 更改为th。这也有效:callback = JS(c("$('table.dataTable thead th').css('border-bottom', 'none');", "$('table.dataTable.no-footer').css('border-bottom', 'none');")), 谢谢!
    猜你喜欢
    • 2014-04-08
    • 2020-02-25
    • 1970-01-01
    • 2018-06-13
    • 2022-10-06
    • 2011-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多