Using brilliant inputs to the output of a DataTable

I would like to dynamically create a series of input widgets for use on each row of the data table. I can successfully display such a list of inputs in a table, however, I am having problems accessing the value of these dynamic inputs.

ui.R

library(shiny)

ui <- fluidPage(

  fluidRow(
    radioButtons('original','Normal Radio Button',c('1','2','3','4','5')),
    DT::dataTableOutput("table")
  )
)

server.R

library(DT)

multipleRadio <- function(FUN, id_nums, id_base, label, choices, ...) {

  inputs <- 1:length(id_nums)
  for (i in 1:length(inputs)) {
    inputs[i] <- as.character(FUN(paste0(id_base, id_nums[i]),label, choices, ...))
  }

  return(inputs)
}

radio_inputs <- multipleRadio(radioButtons,
                       as.character(1:3),
                       'input_',
                       'Radio Button',
                       c('1','2','3','4','5'),
                       inline = TRUE)

output_table <- data.frame(id = c(1,2,3),
                           name=c('Item 1','Item 2','Item 3'),
                           select = radio_inputs)


server <- function(input, output, session) {

  observe({
    print(paste('original: ',input$original))
    print(paste('input 1: ',input$input_1))
    print(paste('input 2: ',input$input_2))
    print(paste('input 3: ',input$input_3))
 })

  output$table <- renderDataTable({   
    datatable(output_table,rownames= FALSE,escape = FALSE,selection='single',
            options = list(paging = FALSE,ordering=FALSE,searching=FALSE))
  })
}

, radioButton HTML, as.character. , "input_1", "input_2" "input_3". . radioButtons , . . , input$input_1, input$input_2 input$input_3, , . , , !

Edit:

: http://www.stackoverflow.red/questions/32993257/shiny-datatables-with-interactive-elements

Shiny.bindAll datatable, , HTML Shiny input.

output$table <- renderDataTable({ 
    datatable(output_table,rownames= FALSE,escape = FALSE,selection='single',
              options = list(paging = FALSE,ordering=FALSE,searching=FALSE, 
                             preDrawCallback=JS('function() { Shiny.unbindAll(this.api().table().node()); }'),
                             drawCallback=JS('function() { Shiny.bindAll(this.api().table().node()); } ')))
})
+4
1

shiny - shiny.tag, data.frame. , :

as.data.frame.default(x [[i]], optional = TRUE, strAsAsFactors = stringsAsFactors): "shiny.tag" " data.frame

radio_inputs, , character, HTML-. , , .

, - HTML, .

0

All Articles