Change Datatables Column Heading Cell Padding

1,125 views
Skip to first unread message

Dario Strbenac

unread,
Jul 21, 2015, 9:00:08 PM7/21/15
to Shiny - Web Framework for R
I am trying to modify the example in section 4.3 of the documentation by adding 'padding' : '1px' to the list of arguments, but it has no effect on the displayed table. How can padding be modified for the column names ? It is easy to apply custom padding to the data cells with formatStyle.

Yihui Xie

unread,
Jul 22, 2015, 3:22:51 PM7/22/15
to Dario Strbenac, Shiny - Web Framework for R
this.api().table().header() returns the <thead> node, and what you
were trying to do was to add the padding to the cells in the header,
which means you have to find the <th>'s in <thead>, e.g.

library(DT)
datatable(head(iris, 20), options = list(
initComplete = JS(
"function(settings, json) {",
"$(this.api().table().header()).find('th').css({'padding': '25px'});",
"}")
))

http://datatables.net/reference/api/table().header()

Regards,
Yihui

Dario Strbenac

unread,
Jul 22, 2015, 8:00:06 PM7/22/15
to Shiny - Web Framework for R
I need to learn jQuery one day!
Reply all
Reply to author
Forward
0 new messages