DT rows_selected after canceling a filter value

116 views
Skip to first unread message

Ulrich Rechberg

unread,
Jun 15, 2016, 8:19:40 AM6/15/16
to Shiny - Web Framework for R
Seems to me that input$<DT>_rows_selected misses an update after canceling a filter value.

Example
Client-side Table:
select: row 3
filter: 10 (-> Showing 1 to 6 of 6 entries (filtered from 50 total entries)). Plot now marks the corresponding node.
select: row 7. Plot now marks a different node.
cancel filter: (-> Showing 1 to 10 of 50 entries). DT now shows two selected entries (which is correct), but the plot shows only one, missing the first selection.
select: row 5. DT and plot table now both show three entries (which is correct).

Yihui Xie

unread,
Jun 15, 2016, 11:44:10 AM6/15/16
to Ulrich Rechberg, Shiny - Web Framework for R
Thanks for the report! I can reproduce the issue, but I don't know
what to do in this case: should I unselect or keep the selected rows
that are not present after the filter is applied?

Regards,
Yihui
> --
> You received this message because you are subscribed to the Google Groups
> "Shiny - Web Framework for R" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to shiny-discus...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/shiny-discuss/d8575aad-2e81-4521-a6a4-f2b17bdd3421%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Ulrich Rechberg

unread,
Jun 17, 2016, 10:22:57 AM6/17/16
to Shiny - Web Framework for R, u_rec...@yahoo.de
Thanks for your reply!

Well, after changing a filter value the parameter input$<DT>_rows_selected should be updated in a way that it reflects all selected rows within the current filter range. 

F.i. in your example:
Select row 5;
Filter: 10; now 5 is no longer visible in the table, because it's not in the filter range, but it is still marked in the plot;
Select row 7; now 7 instead of 5 is marked in the plot. Correct;
Change Filter value from 10 to 1; the table shows rows 5 and 7 as selected (correct). The plot, however, has not changed;
Select row 9: the plot now shows three marked nodes. Correct.

Currently input$<DT>_rows_selected doesn't seem to respond to changes of filter values. 
So, yes, keep an eye on previous selections. 
The table display seems correct.

Regards,
Ulrich

Yihui Xie

unread,
Jul 26, 2016, 6:25:30 PM7/26/16
to Ulrich Rechberg, Shiny - Web Framework for R
I thought about this again, and actually you can decide by yourself
whether you want to keep the previously selected rows or not by using
input$tableId_rows_all, which gives you the indices of all rows after
filtering. You can do intersect(input$tableId_rows_selected,
input$tableId_rows_all) to exclude the rows previously selected but
not in the current view after filtering.

Regards,
Yihui


On Fri, Jun 17, 2016 at 9:22 AM, 'Ulrich Rechberg' via Shiny - Web
> https://groups.google.com/d/msgid/shiny-discuss/3210f201-9b0b-4ee5-8ffa-20dd75ab829f%40googlegroups.com.

Ulrich Rechberg

unread,
Aug 9, 2016, 1:39:14 PM8/9/16
to Shiny - Web Framework for R, u_rec...@yahoo.de
Yihui, once again thank you for your reply!
Unfortunately I don't see yet the solution to my issue for a client-side table.

If you take my first example, where you first select row 3, then filter on 10, then select row 7 and then cancel the filter: Here you end up with, in my opinion, to few entries in variable input$x1_rows_selected: It only contains row 7, not {3,7}. Intersection cannot help to recover missing rows.

For a server-side table this problem does not exist: Start again with selection of row 3 (Datsun 710), then filter on 360, then select row 2 (Duster 360) and cancel the filter. input$x3_rows_selected contains rows 3 and 7. This I would like to see also for the client-side table, i.e. for input$x1_rows_selected.

Best regards,
Ulrich

Yihui Xie

unread,
Aug 9, 2016, 11:10:08 PM8/9/16
to Ulrich Rechberg, Shiny - Web Framework for R
Good point. I think the behavior of server-side tables makes more
sense, so I just changed the behavior of client-side tables to be
consistent with server-side tables, e.g. input$tableId_rows_selected
will include the selected rows even if they are excluded by filtering.
This change was made in the development version of DT:

devtools::install_github('rstudio/DT')

Regards,
Yihui


On Tue, Aug 9, 2016 at 12:39 PM, 'Ulrich Rechberg' via Shiny - Web
> https://groups.google.com/d/msgid/shiny-discuss/0f824db9-2dc4-4f2a-9989-d18f21548dd1%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages