79120620

Date: 2024-10-24 06:32:37
Score: 0.5
Natty:
Report link

You could use reactable and reactable.extra see reactable.extra documentation for custom input

Created an example code snippet using your example here;

library(shiny)
library(reactable)
library(reactable.extras)

shinyApp(
  ui = fluidPage(
    reactable.extras::reactable_extras_dependency(),
    reactableOutput("react"),
    hr(),
    textOutput("button_text"),
    textOutput("text")
  ),
  server = function(input, output) {
    output$react <- renderReactable({
      # preparing the test data
      df <- data.frame(
        Name = c('Dilbert', 'Alice', 'Wally', 'Ashok', 'Dogbert'),
        Motivation = c(62, 73, 3, 99, 52),
        Actions = c('Fire'),
        stringsAsFactors = FALSE,
        Text = c(""),
        row.names = 1:5
      )
      reactable(
        df,
        columns = list(
          Actions = colDef(
            cell = button_extra("button", class = "button-extra")
          ),
          Text = colDef(
            cell = text_extra(
              "text"
            )
          )
        )
      )
    })
    output$button_text <- renderText({
      req(input$button)
      values <- input$button
      paste0(
        "Button: ",
        string_list(values)
      )
    })

    output$text <- renderText({
      req(input$text)
      values <- input$text
      paste0(
        "Dropdown: ",
        string_list(values)
      )
    })
  }
)
Reasons:
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Zekiye