Saving the state of sorted items - Feature?
sarthi2395 opened this issue · 1 comments
sarthi2395 commented
First of all, great package!
I was wondering if I can retrieve the order in which elements are sorted by the user, save it somewhere and re-render the UI using the updated order when they open the app the next time. Is there a way I can export the sorted order from UI?
Yang-Tang commented
Hi @sarthi2395 actually, there is an experimental implement of such feather in the GitHub version shinyjqui by using the shiny's bookmarking state. See example here:
library(shiny)
library(shinyjqui)
server <- function(input, output) {
output$lst_order <- renderPrint({
cat('List1: ')
cat(input$lst1)
cat('\n')
cat('List2: ')
cat(input$lst2)
cat('\n')
cat('List3: ')
cat(input$lst3)
cat('\n')
cat('List4: ')
cat(input$lst4)
cat('\n')
})
jqui_bookmarking()
}
ui <- function(resquest) {fluidPage(
bookmarkButton(),
orderInput('lst1', 'List1', items = month.abb, item_class = 'info'),
orderInput('lst2', 'List2 (can be moved to List1 and List4)', items = month.abb,
connect = c('lst1', 'lst4'), item_class = 'primary'),
orderInput('lst3', 'List3 (can be copied to List2 and List4)', items = month.abb,
as_source = TRUE, connect = c('lst2', 'lst4'), item_class = 'success'),
orderInput('lst4', 'List4 (can be moved to List2)', items = NULL, connect = 'lst2',
placeholder = 'Drag items here...'),
verbatimTextOutput('lst_order')
)}
enableBookmarking(store = "url")
shinyApp(ui, server)
Hope this helps.