From this post I gather we should define an alignRight
CSS class with the desired alignment:
# ui.R
sidebarLayout(...,
mainPanel(
tags$head(
tags$style(".alignRight { align: right; }", media = "all", type = "text/css")
),
... # content with call to dataTableOutput("myTable")
)
)
and then when creating the DataTable, use the aoColumnDefs
option to set class of the desired columns to alignRight
:
# server.R
shinyServer(
function(input, output) {...
output$myTable <- renderDataTable(...,
options = list(
aoColumnDefs = '[{"aTargets": [7, 9, 10], "sClass": "alignRight"}]'
)
)
}
)
However, this has had no effect on my DataTable, when remains left aligned for all columns. I thought a simple alignment issue would be easy to sort out, but after many hours, apparently not so. Any ideas would be much appreciated.
The following works fine with no custom class definition:
option=list(columnDefs=list(list(targets=3:5, class="dt-right")))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With