1

I am using the package DT to create a datatable. I want to remove the table border. Any suggestions?

datatable(head(mtcars), rownames = NULL, colnames = NULL, options = list(dom = "t"))

enter image description here

Fisseha Berhane
  • 2,533
  • 4
  • 30
  • 48
  • I cannot see any options to control this. Do you just need a simple HTML table with no borders / headers ? – LyzandeR Jul 24 '17 at 15:36
  • I want to use it in Shiny and I want to include a datatable cell with an image and I want a modal window to show on clicking the image. The modal window contains information on what the image is. – Fisseha Berhane Jul 24 '17 at 17:48
  • see https://stackoverflow.com/questions/52248958/datatable-remove-all-horizontal-borders/52262553 – Stéphane Laurent Sep 10 '18 at 20:52

1 Answers1

1

I 'll provide an answer with tableHTML that you might find useful for such a task:

library(tableHTML)
#create the HTML table. setting border to zero will remove borders
tableHTML(mtcars, headers = rep(' ', 11), rownames = FALSE, border = 0,
          widths = rep('60', 11)) %>%
  #add some css odd rows to keep zebra colouring. You can choose any colour you like
  add_css_row(list('background-color', 'lightgray'), rows = even(1:nrow(mtcars)))

You can still change cell spacing, fonts, background colours or anything else you like with CSS using the add_css_* functions.

Output:

enter image description here

LyzandeR
  • 37,047
  • 12
  • 77
  • 87
  • Thanks for the answer. Can I use this in Shiny and can I make one of the columns an image. I want a modal window to show on clicking the image. The modal window contains information about the image. – Fisseha Berhane Jul 24 '17 at 17:49
  • `tableHTML` is compatible with [shiny](https://cran.r-project.org/web/packages/tableHTML/vignettes/tableHTML.html). You could use an image within a cell I suppose (by providing the ` – LyzandeR Jul 24 '17 at 18:35
  • Thanks. I tried it with shiny. But it does not render an image in a cell: https://stackoverflow.com/questions/45288069/tablehtml-in-shiny-show-an-image-in-a-cell – Fisseha Berhane Jul 24 '17 at 19:05