Last active
July 1, 2019 12:12
-
-
Save juba/fcc44d15f76c8bdf0c1640bbcd610648 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Generate unique id for this table | |
tab_id <- paste0("mytab_", session$token) | |
output$table <- DT::renderDT({ | |
## Enable stateSave and configure callbacks to save and restore state | |
## to/from sessionStorage | |
options <- list( | |
stateSave = TRUE, | |
stateSaveCallback = DT::JS(paste0("function(settings, data) { | |
sessionStorage.setItem('", tab_id, "', JSON.stringify(data)); | |
}")), | |
stateLoadCallback = DT::JS(paste0("function(settings, callback) { | |
return JSON.parse(sessionStorage.getItem('", tab_id, "')); | |
}")) | |
) | |
## Generate dataTable with options | |
DT::datatable(df(), options = options) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment