如何为Shiny数据表添加列边框?

时间:2018-06-18 22:05:13

标签: r datatable shiny shinydashboard dt

我有一个闪亮的数据表,如下所示:

enter image description here

但是,我希望它在所有单元格周围都有完整的边框,使其看起来更像excel表格。我知道在闪亮的表中,它就像调用bordered = T一样简单,但这对于Shiny中的数据表不起作用。

这是我的用户界面代码:

      fluidRow(
        DT::dataTableOutput("stats_table", width = "95%")
      )

这是我的服务器代码:

output$stats_table <- DT::renderDataTable(DT::datatable({
  # Do not show a plot when the page first loads
  # Wait until the user clicks "Plot" button
  if (input$plot_graph_button == 0)
    return()

  data <- summary_table
  #### Do some filtering here ####
  data

}))

提前感谢您的帮助,我觉得这应该是一个非常简单的解决方案,但是,我没有找到任何有关它的好信息。我确实认识到这纯粹是装饰性的,不会影响桌子的功能。

1 个答案:

答案 0 :(得分:1)

您可以使用cell-border stripe课程。查看here了解更多选项

 output$stats_table <- DT::renderDataTable({
               # Do not show a plot when the page first loads
               # Wait until the user clicks "Plot" button
               # if (input$plot_graph_button == 0)
               # return()

       data <- datatable(head(iris), class = 'cell-border stripe')
       #### Do some filtering here ####
       data

})