rstudio / DT

R Interface to the jQuery Plug-in DataTables
https://rstudio.github.io/DT/
Other
587 stars 184 forks source link

plugins = 'natural' not working for DT v > .27? #1099

Closed alanfarahani closed 7 months ago

alanfarahani commented 7 months ago

Hi all,

One last potential bug. As far as I can tell, the plugins = 'natural' argument does not work in DT versions 0.28, 0.29, or 0.30. I tested each version using devtools::install_version("DT", version = "0.27", repos = "http://cran.us.r-project.org")

The last functioning version for me is 0.27. The MRE that I used was the one provided by Yihui in his response on SO to this issue.

Thanks.

Examples (based on same MRE below):

DT v.0.27 DT_27

DT v.0.30 DT_30

MRE:

library(shiny)
library(DT)
shinyApp(
  ui = fluidPage(
    DT::dataTableOutput('example')
  ),
  server = function(input, output) {
    output$example <- DT::renderDataTable({
      table = cbind(LETTERS[1:5],matrix(1:20,nrow=5),c(1,2,3,10,"a"))
      table = rbind(c("filtered",round(rnorm(5),3)),table)
      table
    }, server = FALSE, plugins = 'natural', options = list(
      columnDefs = list(list(type = "natural", targets = "_all"))
    ))
  }
)

Versions: R version 4.3.0 (2023-04-21 ucrt) Windows 10 x64 (build 19045) shiny: 1.80 htmltools: 0.5.7


By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

yihui commented 7 months ago

Please follow the issue guide at the bottom of your post. In particular, the second item in the list suggested that you try the dev version. I think this issue has already been fixed in the dev version (due to #1091, which included a fix to a bug in DataTables that probably caused the problem you reported). Thanks!

alanfarahani commented 7 months ago

Of course! I did try the dev version, and it wasn't working for me (at the time), even with server = FALSE. It is now. Thanks for this fix, and following up.

yihui commented 7 months ago

Good to know! You probably forgot to restart R after installing the dev version (in general, you need to restart R after installing any package that's already loaded in the current R session).