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.