Skip to content

Update material dropdown : selected with multiple values#90

Open
bilbaoba wants to merge 1 commit intoericrayanderson:masterfrom
bilbaoba:update_material_dropdown_multiple_values
Open

Update material dropdown : selected with multiple values#90
bilbaoba wants to merge 1 commit intoericrayanderson:masterfrom
bilbaoba:update_material_dropdown_multiple_values

Conversation

@bilbaoba
Copy link
Contributor

@bilbaoba bilbaoba commented Apr 9, 2019

Hi Eric & shinymaterial users,

I propose to answer issue #89 with this PR.

Changes :

  • Code modification to allow parameter value to be a vector.
  • Improvement & simplification of code

Test :

After install the package :

rm(list = ls())
library(shiny)
library(shinymaterial)

ui <- material_page(
  title = "Demo Update Dropdown",
  material_dropdown(input_id = 'test', label = 'toto', choices = c("a", "b", "c"), selected = c("b","c"), multiple = T),
  material_button(input_id = "button_test", label = "test"),
  material_button(input_id = "button_test_2", label = "test2"),
  material_card(
    title = "Material dropdown value : ",
    uiOutput('renderInputTest')
  )
)

server <- function(input, output, session) {
  observeEvent(input$button_test, {
    if (input$button_test > 0)
      update_material_dropdown(session, input_id = 'test', value = "aa", choices = c("aa", "bb", "cc"))
  })
  
  observeEvent(input$button_test_2, {
    if (input$button_test_2 > 0)
      update_material_dropdown(session, input_id = 'test', value = c("dd", "gg"), choices = c("dd", "ee", "ff", "gg"))
  })
  
  output$renderInputTest <- renderText({
    print(input$test)
    input$test
  })
  
}

shinyApp(ui = ui, server = server)

Suggestion :

  • Change parameter value to selected

@bilbaoba bilbaoba force-pushed the update_material_dropdown_multiple_values branch from ac69cb8 to 95b52dc Compare April 9, 2019 10:31
@bilbaoba
Copy link
Contributor Author

Hi @ericrayanderson ,

This PR had a conflict, I resolve it.
Simply put formSelect instead of material_select in my PR.
I test this PR and it's working with the newest version of package (v1.0.0) and it resolve issue #89.

Regards.

@bilbaoba bilbaoba force-pushed the update_material_dropdown_multiple_values branch 2 times, most recently from f8b77a0 to 60c5101 Compare January 29, 2020 18:22
@bilbaoba bilbaoba force-pushed the update_material_dropdown_multiple_values branch from 8ea78f1 to 0254f96 Compare August 26, 2020 06:06
@bilbaoba
Copy link
Contributor Author

Hi @ericrayanderson,

This PR had a conflict due to your correction of the missing quote into the function.
I simply update my branch.
It still resolve issue #89 and allow users to update multiple choices and also update the choices list.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant