stateSave and clearing filters

1,358 views
Skip to first unread message

Steven Wasik

unread,
Jun 21, 2016, 9:43:46 AM6/21/16
to Shiny - Web Framework for R
I am using the following code to repopulate filters directly following a data refresh.  The issue is that when I set stateSave = TRUE, datatable will “remember” filter settings from a previous session that were never explicitly saved and that I am not telling it to use.  I can resolve this issue by reloading the data 4 or 5 times, but this won’t work for production.  Is there any way to clear the stateSave or the filters?  Is there another way to address this issue?






 

 datatable(visible_data$my_dat,  selection = 'single', filter = list(position = 'top', clear = TRUE),

                  options = list(stateSave = TRUE, pageLength = 20, autoWidth = TRUE, 

                                 searchCols = list(list(search =  table_state$table_state$columns[[1]]$search$search), list(search =  table_state$table_state$columns[[2]]$search$search), list(search =  table_state$table_state$columns[[3]]$search$search),

                                                   list(search =  table_state$table_state$columns[[4]]$search$search), list(search =  table_state$table_state$columns[[5]]$search$search), 

                                                   list(search =  table_state$table_state$columns[[6]]$search$search), list(search =  table_state$table_state$columns[[7]]$search$search), 

                                                   list(search =  table_state$table_state$columns[[8]]$search$search), list(search =  table_state$table_state$columns[[9]]$search$search), 

                                                   list(search =  table_state$table_state$columns[[10]]$search$search), list(search =  table_state$table_state$columns[[11]]$search$search), 

                                                   list(search =  table_state$table_state$columns[[12]]$search$search), list(search =  table_state$table_state$columns[[13]]$search$search))))

 

Steven Wasik

unread,
Jun 21, 2016, 5:27:15 PM6/21/16
to Shiny - Web Framework for R
So I have identified what I think is the issue: If I delete everything from local storage in More Tools>Developer Tools>Resources>Local Storage>Server:3838 Shiny no longer "remembers" previous filter inputs and thus does not apply them.

I'd like this web app to immediately delete the information for Local Storage before it does anything else to ensure the tables always get displayed properly .  Any advice on how to do this? 

Yihui Xie

unread,
Jun 26, 2016, 11:45:17 AM6/26/16
to Steven Wasik, Shiny - Web Framework for R
I'm confused: when do you want to clear the state of the table?

Regards,
Yihui

Steven Wasik

unread,
Jun 26, 2016, 3:11:56 PM6/26/16
to Shiny - Web Framework for R, steven....@gmail.com


I want to clear the state of the table when a user opens the app in their web browser. 



Best,

Steve

Yihui Xie

unread,
Jun 26, 2016, 11:54:39 PM6/26/16
to Steven Wasik, Shiny - Web Framework for R
I tested the table.state.clear() api of DataTables, and found it
didn't work for some reason. However, for your problem, it may suffice
to only clear the filters, so I added a clearSearch() method to the
lastest version of DT on Github: https://github.com/rstudio/DT

proxy = dataTableProxy('your_table_id')
clearSearch(proxy)

But this sounds meaningless to me: the purpose of saving the state of
a table is to preserve all the settings the next time you load the
page, so I don't quite understand why you want to save the state...

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/48dbfe50-d313-4c68-ad4c-7eda4d18fdd0%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Steven Wasik

unread,
Jun 27, 2016, 12:28:59 AM6/27/16
to Shiny - Web Framework for R, steven....@gmail.com
We are implementing an application where a user can enter new information into a data.frame that is displayed using DT.

Steps:
1) Highlight a row and then press a button to pull up a pop-up form.  
2) This pop up has fields for the user to enter new information.
3) User pushes a save button which immediately results in the new information being shown in the table.  


This series of events reloads the table.  If stateSave = FALSE, the sorting and filtering applied by our users is immediately removed.



Steve

Steven Wasik

unread,
Jun 27, 2016, 2:08:30 AM6/27/16
to Shiny - Web Framework for R, steven....@gmail.com
The solution you have created (Thanks!) requires the latest Git Hub version of DT but we are currently only have the latest CRAN version which does not support dataTableProxy.

We currently run several production level applications that cannot go down.  Are there any known issues that may result from switching from latest CRAN version of DT to the latest Git Hub version of DT?

Thanks,

Steve

Yihui Xie

unread,
Jul 20, 2016, 6:44:21 PM7/20/16
to Steven Wasik, Shiny - Web Framework for R
I'm working on a new CRAN release of DT starting this week, and will
post an announcement once it is ready for testing. All changes have
been documented at https://github.com/rstudio/DT/blob/master/NEWS.md I
tried my best not to break anything but it is hard to tell if I missed
anything.

Actually your problem may be better solved if I could implement this
feature for the coming release:
https://github.com/rstudio/DT/issues/208

Regards,
Yihui
> https://groups.google.com/d/msgid/shiny-discuss/1267d5f1-587d-438b-b7ca-96d79d64abe0%40googlegroups.com.

Steven Wasik

unread,
Jul 20, 2016, 10:31:59 PM7/20/16
to Shiny - Web Framework for R, steven....@gmail.com
Thank you very much for the heads up! I will ensure that my team does extensive testing to ensure that our application continues to function properly following the upcoming CRAN release.

I agree that feature 208 is likely a more general solution, I look forward to trying it out when it has been implemented.

Best,

Steve

Joe Cheng

unread,
Jul 20, 2016, 11:37:18 PM7/20/16
to Steven Wasik, Shiny - Web Framework for R
You might consider using packrat to protect your deployed Shiny apps from package version breakage. With packrat, each application has its own isolated package library. I don't have the links in front of me but searching "packrat" and "packrat shiny server" should turn up appropriate results.
Reply all
Reply to author
Forward
0 new messages