Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"dt-center" not working for numeric variables (#476 is back) #511

Closed
vnijs opened this issue Feb 23, 2018 · 4 comments · Fixed by #512
Closed

"dt-center" not working for numeric variables (#476 is back) #511

vnijs opened this issue Feb 23, 2018 · 4 comments · Fixed by #512
Milestone

Comments

@vnijs
Copy link
Contributor

vnijs commented Feb 23, 2018

Seems like #476 is back in 0.4 and 0.4.1 on GitHub

image

library(shiny)
shinyApp(
  ui = fluidPage(DT::dataTableOutput("tab")),
  server = function(input,output){
    output$tab <- DT::renderDataTable({
      DT::datatable(
        head(iris),
        options = list(
          columnDefs = list(
            list(className = "dt-center", targets = "_all")
          )
        )
      )
    })
  }
)

image

@shrektan
Copy link
Collaborator

Confirmed. Thanks for reporting. Will investigate now...

@shrektan
Copy link
Collaborator

shrektan commented Feb 24, 2018

It looks like the fix #476 misses the fact that besides of column indexes, there're 4 kinds of columnDefs.targets in total.

  • 0 or a positive integer - column index counting from the left
  • A negative integer - column index counting from the right
  • A string - class name will be matched on the TH for the column (without a leading .)
  • The string "_all" - all columns (i.e. assign a default)

@vnijs
Copy link
Contributor Author

vnijs commented Feb 26, 2018

Works. Thank you!

image

@BetweenTwoTests
Copy link

BetweenTwoTests commented Mar 6, 2018

For those who cannot use dev version of DT, list(className = "dt-head-center dt-center", targets = "_all") does the trick for me (DT 0.4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants