1

I have a shiny datatable that looks like this:

enter image description here

However, I want it to have full borders around all of the cells to make it look more like an excel sheet. I know in the shiny table it is as simple as calling bordered = T but that does not work for the datatable in Shiny.

This is my UI code:

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

And this is my server code:

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

}))

Thank you in advance for the help, I feel like this should be a very easy fix, however, I am not finding any good information on it. I do realize this is purely cosmetic and does not effect the functionality of the table.

  • It is much easier to help if you include a minimum reproducible example: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Ian Wesley Jun 18 '18 at 22:48
  • I think this question has already been answered : https://stackoverflow.com/questions/50751568/add-cell-borders-in-an-r-datatable/50754794#50754794 . Is that what you are looking for ? –  Jun 19 '18 at 01:24
  • 1
    @Aureliencallens I tried that code and it actually does not work with the syntax I have. I did see that example before posting my question. It is close to what I need but not quite correct. –  Jun 19 '18 at 14:21

1 Answers1

4

You can use cell-border stripe class. Check here for more options

 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

})
A. Suliman
  • 12,923
  • 5
  • 24
  • 37