shinyjqui
shinyjqui copied to clipboard
[Feature Request]Add or remove options within two orderinputs by clicking on them, not just dragging them
At first I was using multiInput in shinyWidgets, it's useful to have multiple selections but it's impossible to read the order of the selected items, but it seems that the author answered the question about sorting, and the answer is that it's difficult, so I found your package, and the orderInput is really excellent and user-friendly!
Is it possible to create a standalone xxxxInput combining the features of multiselect and sorting by dragging.
BTW, it would be very user friendly if the parameter contains direction.
These are my humble opinions and suggestions!
Thanks for the nice suggestion! I find an imperfect solution to this by using jqui_sortable
:
library(shiny)
library(shinyWidgets)
library(shinyjqui)
js <-JS('
function(event, ui) {
$(this).children("select").on("change", function() {
$(this).parent(".shiny-input-container").trigger("sortupdate");
})
}
')
ui <- fluidPage(
jqui_sortable(
multiInput(
inputId = "id", label = "Fruits :",
choices = c("Banana", "Blueberry", "Cherry",
"Coconut", "Grapefruit", "Kiwi",
"Lemon", "Lime", "Mango", "Orange",
"Papaya"),
selected = "Banana", width = "350px"
),
options = list(
# to make the selected items sortable
items = "> .multi-wrapper > .selected-wrapper > a",
# on multiInput changes, update sortable as well
create = js
)
),
"multiInput_original",
verbatimTextOutput(outputId = "res"),
"multiInput_w_sortable",
verbatimTextOutput(outputId = "res2")
)
server <- function(input, output, session) {
output$res <- renderPrint({
input$id
})
output$res2 <- renderPrint({
input$id_order$text
})
}
shinyApp(ui = ui, server = server)
With the above code, you can now sort the selected items by drug&drop and get the sorted order. However, the order is reset once the items are removed or added. This is the internal logic of multi.js
that we can't change.