I'm trying to format datatable in R using DT package. I have code like this: library(data.table) library(DT) data<-data.table(rbind(c(1,2,3),c(4,5,6))) colnames(data)<- c('A','B','c') datatable(data, rownames=F, colnames=c('A','B','C'), class='stripe cell-border hover', options=list( pageLength=100, dom='ltp', initComplete = JS(" function(settings, json) { $(this.api().table().body()).css({ 'background-color': 'red', 'outline-color': 'red', 'margin':'100px', 'color': 'violet', 'text-align': 'center', 'font-family': 'Courier New', 'border-radius': '25px' }); $(this.api().table().header()).css({ 'background-color': '#000', 'color': '#fff', 'outline-color': 'red', 'margin':'100px', 'text-align': 'center', 'font-family': 'Courier New', 'border-radius': '25px' }); } ") ), caption = htmltools::tags$caption( style = 'caption-side: top; text-align: center; color:black; font-size:200% ;','Table'), filter=list(position = 'top') ) And I have problem with javascript in function JS(). It modifies background color (but only in header), font color and style. But commands to align text or round corners don't work. Why does it work like that? And how can I modify code to format this other things? Regards, Jeddite [[alternative HTML version deleted]]
Can anybody help with this problem? 2017-05-22 11:32 GMT+02:00 Krzysiek Gniady <jeddite4 at gmail.com>:> I'm trying to format datatable in R using DT package. I have code like > this: > > library(data.table) > library(DT) > data<-data.table(rbind(c(1,2,3),c(4,5,6))) > colnames(data)<- c('A','B','c') > > datatable(data, rownames=F, > colnames=c('A','B','C'), > class='stripe cell-border hover', > options=list( > pageLength=100, > dom='ltp', > initComplete = JS(" > function(settings, json) { > $(this.api().table().body()).css({ > 'background-color': 'red', > 'outline-color': 'red', > 'margin':'100px', > 'color': 'violet', > 'text-align': 'center', > 'font-family': 'Courier New', > 'border-radius': '25px' > }); > $(this.api().table().header()).css({ > 'background-color': '#000', > 'color': '#fff', > 'outline-color': 'red', > 'margin':'100px', > 'text-align': 'center', > 'font-family': 'Courier New', > 'border-radius': '25px' > }); > } > ") > ), > caption = htmltools::tags$caption( > style = 'caption-side: top; text-align: center; color:black; > font-size:200% ;','Table'), > filter=list(position = 'top') > ) > > And I have problem with javascript in function JS(). It modifies > background color (but only in header), font color and style. But commands > to align text or round corners don't work. > > Why does it work like that? And how can I modify code to format this other > things? > > > Regards, > > Jeddite >[[alternative HTML version deleted]]