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

minor colReorder problem remaining #534

Closed
gergness opened this issue Apr 26, 2018 · 4 comments · Fixed by #1096
Closed

minor colReorder problem remaining #534

gergness opened this issue Apr 26, 2018 · 4 comments · Fixed by #1096

Comments

@gergness
Copy link
Contributor

#532 is awesome, thanks so much @shrektan ! I did encounter one remaining bug - it only happens with server set to TRUE, so possibly it should just be mentioned in the documentation.

To reproduce:

  1. Create a DT with colReorder, a filter, and with server set to TRUE
  2. Use the filter to filter a column
  3. Reorder the column that you've just filtered
  4. Try to reset the filter

When you do this, it's clear that the filter isn't being applied to the right column. In the example below, I get a javascript popup about the numeric type vs character type, but if all columns are character, then there's no error but I believe the old filter is applied to the wrong column.

# Same a #531 but this problem is only for server=TRUE
library(shiny)
library(DT)

ui <- basicPage(
  DT::dataTableOutput('foo')
)

server <- shinyServer(function(input, output, session) {
  output$foo = DT::renderDataTable(
    iris, server = TRUE,
    filter = "top", 
    caption = 'colReorder + filter can have trouble',
    extensions = 'ColReorder',
    options = list(colReorder = TRUE)
  )
})
runApp(shinyApp(ui, server))

Initial State

image

Set filter

image

Move filtered column

image

Try to reset filter

image

@shrektan
Copy link
Collaborator

I can confirm this. It seems like the server doesn't capture the right column info for sorting. I'll investigate it.

@shrektan
Copy link
Collaborator

shrektan commented Apr 28, 2018

There're two issues, in fact:

  1. If one filter is in using and gets reordered (e.g., the fifth being moved to the second ), the search text info sent to the server side will use the new position (the second). This is odd because it's the original column position that should be sent to the server... I think we may be able to fix it if we call the filter event again, whenever the column gets reordered.
  2. The sorted position info being sent to the server is always the new position. However, the datatables library doesn't send the col-reorder info to the server... How to let the server knows the current column orders? I don't really know...
    Using object data can help this (since the column name will be returned back to the server that can be used to deduct the col-order) but it's difficult to implement correctly without introducing new bugs (there're so many combination cases and no unit tests 😨 )... It seems not worth the try...

Suddenly what @yihui blogged in https://yihui.name/en/2018/01/back-to-dt/ comes to my mind ... 😹

The core features are okay, but the extensions… They are my biggest headache, but they do look useful, so users love using them, but are constantly surprised why they don’t work in certain cases. Again, it is due to the combinatorial effect.

@shrektan
Copy link
Collaborator

shrektan commented Feb 5, 2020

I don't think we might be able to fix this but we should document it.

@yihui
Copy link
Member

yihui commented Nov 16, 2023

It's finally fixed, after 5.5 years... You can test the development version via

remotes::install_github('rstudio/DT')

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

Successfully merging a pull request may close this issue.

3 participants