user1357015
user1357015

Reputation: 11676

Right align columns in Shiny dataTable

I have a Shiny data table that I am trying to right align. The data table has 2 columns.

I am using the following options:

  ,options= list(paging = FALSE, searching = FALSE, sorting = FALSE,  bFilter = FALSE, bSort = FALSE, bInfo = FALSE, bAutoWidth = TRUE, 
                 aoColumnDefs = list(list(sClass="alignRight",aTargets=c(list(1), list(2))))

What am I missing

Upvotes: 4

Views: 2170

Answers (1)

NicE
NicE

Reputation: 21425

You could add a rowCallback function to your list of options to align the text to the right using CSS (there doesn't seem to be any rightAlign or dt-right class styles in the CSS stylesheets loaded by shiny):

rowCallback = I(
    'function(row, data) {
        $("td", row).css("text-align", "right");
      }'
  )

Upvotes: 1

Related Questions