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

Row selection for the server-side processing mode #75

Closed
yihui opened this issue May 24, 2015 · 5 comments
Closed

Row selection for the server-side processing mode #75

yihui opened this issue May 24, 2015 · 5 comments

Comments

@yihui
Copy link
Member

yihui commented May 24, 2015

Moving @ReportMort's issue here from #50. Also mentioned by @frajuegies in #20.

@yihui
Copy link
Member Author

yihui commented May 25, 2015

Finally I managed to make row selection work for the server-side processing mode as well. Please update DT from Github, and see Section 2.1: http://rstudio.github.io/DT/shiny.html

@StevenMMortimer
Copy link

@yihui Thanks for working on that, but the trick to do row selection by rowname doesn't really help with large tables when a user won't spend the time to click-select thousands of rows individually. In #50 I was expecting a fix that would make input$tbl_rows_all work with server-side processing so that user searches/filtering would bring back all of the table indices, not just the indices served to the client side. I guess that's just not possible with server=TRUE?

@yihui
Copy link
Member Author

yihui commented May 31, 2015

@ReportMort Unfortunately, you are right. That is not possible with server=TRUE. I have explained the reason at http://rstudio.github.io/DT/shiny.html

I do have the row indices inside the server-side processing function, though: https://github.com/rstudio/DT/blob/master/R/shiny.R#L168 The problem is DataTables does not seem to allow me to pass these indices back to the client: http://datatables.net/manual/server-side

@StevenMMortimer
Copy link

@yihui I am curious to hear your thoughts about adding names to the filter input elements and then adding ChangeInput functions for when the values of those inputs change. Here is an example app I have working to show the filter inputted values and then parsing them to determine the server side row indices: https://reportmort.shinyapps.io/DT-filter-info/

It seems hacky, but wondering if you would be interested in adding more functionalities for the table inputs like this.

Adding Names to Input Elements
https://github.com/ReportMort/DT/blob/master/R/datatables.R#L368L377

A Few Lines Where I Add ChangeInput for Each Filter Input
https://github.com/ReportMort/DT/blob/master/inst/htmlwidgets/datatables.js#L88
https://github.com/ReportMort/DT/blob/master/inst/htmlwidgets/datatables.js#L169
https://github.com/ReportMort/DT/blob/master/inst/htmlwidgets/datatables.js#L229

@yihui
Copy link
Member Author

yihui commented Jun 11, 2015

@ReportMort That probably works, but is certainly inefficient, because you essentially did searching twice. What I would do is to check if it is possible to pass the row indices back from DT:::dataTablesFilter (even though DataTables does not make use of this information), and see if it is possible to use a success callback (http://datatables.net/reference/option/ajax http://api.jquery.com/jQuery.ajax/) to extract the indices, then pass to Shiny.onInputChange(). It looks like you are reasonably familiar with JavaScript, so please see if you can walk down this path.

BTW, the search items are available as input$foo_search_columns: http://rstudio.github.io/DT/shiny.html

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

No branches or pull requests

2 participants