How to add line borders and zebra stripes (line rotation) in datatables DT in R?

I would like to know the correct way to add border style borders and zebra stripes for datatables created with the DT package in R.

An example of a simple launch:

library(DT) datatable(iris) 

A simple example with parameters:

 datatable(head(iris, 20), options = list( columnDefs = list(list(className = 'dt-center', targets = 4)), pageLength = 5, lengthMenu = c(5, 10, 15, 20) )) 

Not sure why I got a low vote? Please let me know if something is unclear or how to improve this question.

+5
source share
1 answer

You can add the stripe and row-border class to the table container:

 library(DT) library(htmltools) datatable( head(iris, 20), container = tags$table( class="stripe row-border", tags$thead(tags$tr(lapply(colnames(iris), tags$th))) ) ) 

This will create a table container with both classes, and the styling function will be applied. You can add any other style from the link you posted.

+7
source

Source: https://habr.com/ru/post/1213384/


All Articles