-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
Hi,
I have a simple app below. There is a "Sort" button and it opens a modalDialog. I want to sort my table on this modal dialog. After I finished sorting, I will click submit button or cancel button and it removes modal dialog. There is nothing wrong for now. However, if you click "Sort" button twice, sortable table loses its features and becomes a normal table. That's why, you can't sort your table.
How can I fix this issue?
Thanks in advance.
library(shiny)
library(shinyjqui)
data <- head(mtcars)
ui <- fluidPage(
# Action Button
actionButton("sl_player_sort","Sort")
)
server <- function(input, output, session) {
# Show modal with action button
observeEvent(input$sl_player_sort, {
showModal(
modalDialog(
title = "Sort",
size = "l",
# Sortable Output
sortableTableOutput("sl_sortable_table"),
easyClose = FALSE,
# Submit & Cancel Button
footer = tagList(
div(
style = "text-align:center;",
actionButton("sl_sort_submit", "Submit", style = "background-color:#39a642; color:white"),
actionButton("sl_sort_cancel", "Cancel", style = "text_align:center;background-color:red; color:white")
)
)
)
)
})
# Render Sortable
output$sl_sortable_table <- renderTable({data})
# Reorder Data with Sortable & Submit
observeEvent(input$sl_sort_submit, {
data<- data[input$sl_sortable_table_order,]
removeModal()
})
# Cancel
observeEvent(input$sl_sort_cancel, {
removeModal()
})
}
shinyApp(ui, server)
Metadata
Metadata
Assignees
Labels
No labels