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

Shiny rows_selected does not react to selectAll Button #366

Closed
andrewsali opened this issue Oct 17, 2016 · 8 comments
Closed

Shiny rows_selected does not react to selectAll Button #366

andrewsali opened this issue Oct 17, 2016 · 8 comments
Milestone

Comments

@andrewsali
Copy link

andrewsali commented Oct 17, 2016

Hi,

It seems the shiny value input$...._rows_selected does not react to the selectAll button from the Select extension. Clicking the "Select All" button correctly selects the rows in the table, but the selection is not sent to Shiny. However, once unselecting a row, the rest of the selection is correctly sent to Shiny.

A minimal example:

library(shiny)
library(DT)

ui <- fluidPage(

  title = 'Select Table Rows',

  h1('A Server-side Table'),

  fluidRow(
    column(9, DT::dataTableOutput('x3')),
    column(3, verbatimTextOutput('x4'))
  )

)

server <- shinyServer(function(input, output, session) {
  # server-side processing
  mtcars2 = mtcars[, 1:8]
  output$x3 = DT::renderDataTable(datatable(mtcars2,options = list(dom = 'B',buttons=c("selectAll","selectNone")),extensions=c("Select","Buttons")), server = TRUE)

  # print the selected indices
  output$x4 = renderPrint({
    input$x1_rows_selected
    s = input$x3_rows_selected
    if (length(s)) {
      cat('These rows were selected:\n\n')
      cat(s, sep = ', ')
    }
  })

})
shinyApp(ui,server)

Thanks,

Andras

@yihui
Copy link
Member

yihui commented Oct 17, 2016

DT has its own implementation of row selections, and does not use the Select extension at all. This may be changed in the future, but I guess it will be a substantial amount of work.

@shrektan
Copy link
Collaborator

I would like to try this as well, but it seems like I have to change lots of codes... It may drive you crazy...

@yihui
Copy link
Member

yihui commented Jan 17, 2018

Right. The work does not sound like trivial. I think the easiest way to go is to bind the Select extension to Shiny, which means there will be two implementations of row selections in DT (the current implementation from scratch in DT, and an implementation based on Select).

I don't plan to do it for the next CRAN release, but please feel free to take a stab at it if you are interested (I guess it might be fun, except... the server mode 😱 ).

@shrektan
Copy link
Collaborator

I suspect Select Extention is only able to select the rows on current page... If that is the case, it may be easier...

@yihui
Copy link
Member

yihui commented Jan 17, 2018

Yes, to some degree, it is limited compared to my implementation. I waited for a long time and finally implemented it by myself, and shortly after that, the Select extension was born... and I was quite embarrassed. Now I'm in this awkward position of re-implementing the missing features from Select.

@shrektan
Copy link
Collaborator

Well that answers my frustration of implementing the selection logic by yourself... Anyway, I’m going to give a try on this but it probably will take some time.

@shrektan
Copy link
Collaborator

Now it works for the client-processing mode, see #744 for details and the example app code.

@shrektan shrektan added this to the v0.12 milestone Jan 17, 2020
@isthisthat
Copy link

@shrektan any chance of making this work for server side mode? Or is there a relevant ticket to watch? Thanks :)

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.

4 participants