title: Generate datatable values dynamically based on inputs from another column
body: <p>I have created a datatable which has selectInput widgets in one of the columns. Another column of the datatable should take inputs given in the first column, and use them to look up a number from my data source. The inputs are binding correctly in Shiny, by using preDrawCallback and drawCallback functions, but lookup values are not updating when the inputs change. Strangely, they do update when I do the lookup in a separate data table. A reproducible example is here:</p>
  
  <pre><code>library(shiny)
  library(DT)
  
  data &lt;- data.frame(c(1:7),c(21:27))
  
  shinyApp(
    server = shinyServer(function(input, output) {
        output$table &lt;- DT::renderDataTable({
  
          Rows &lt;- c(1:7)
          temp &lt;- data.frame(Rows)  
          temp[,"Item"] &lt;- ""
          temp[,"Value"] &lt;- ""
          temp$Rows &lt;- NULL
  
          sapply(1:7, FUN = function(i) {
            temp$Item[i] &lt;&lt;- as.character(selectInput(paste("Item.1.1",i, sep = "."), "",
                                                         choices = setNames(c(1:7),c(1:7)),
                                                         selected = 1,
                                                         multiple = FALSE))
          })
  
           sapply(1:7, FUN = function(i) {
             temp$Value[i] &lt;&lt;- data[eval(parse(text = paste("input$Item.1.1",i, sep = "."))),2]
           })
  
          datatable(temp, escape = FALSE, rownames = FALSE,
                    options = list(sort = FALSE, paging = FALSE, searching = FALSE, dom = 't',
                                   columnDefs = list(list(className = 'dt-center', targets = 0:1)),
                                   preDrawCallback = JS('function() { Shiny.unbindAll(this.api().table().node()); }'),
                                   drawCallback = JS('function() { Shiny.bindAll(this.api().table().node()); } ')
                    ))
      }, server = FALSE)
    }),
    ui = fluidPage(
      dataTableOutput("table")
    )
  )
  </code></pre>
  
  <p>That gives the error "Error in temp$Value[i] &lt;&lt;- data[eval(parse(text = paste("input$Item.1.1",  : 
    replacement has length zero".</p>
  
  <p>I have tried adding this to server:</p>
  
  <pre><code>test &lt;- reactive({
                data.frame(c(ifelse(is.null(input$Item.1.1.1),"",data[eval(parse(text = paste("input$Item.1.1",1, sep = "."))),2]),
                  ifelse(is.null(input$Item.1.1.2),"",data[input$Item.1.1.2,2]),
                  ifelse(is.null(input$Item.1.1.3),"",data[input$Item.1.1.3,2]),
                  ifelse(is.null(input$Item.1.1.4),"",data[input$Item.1.1.4,2]),
                  ifelse(is.null(input$Item.1.1.5),"",data[input$Item.1.1.5,2]),
                  ifelse(is.null(input$Item.1.1.6),"",data[input$Item.1.1.6,2]),
                  ifelse(is.null(input$Item.1.1.7),"",data[input$Item.1.1.7,2])))
              })
  </code></pre>
  
  <p>Then, when I comment out the appropriate sapply within my renderDataTable and instead assign temp[,"Value"] &lt;- test(), I get 21 down the second column of my datatable, and it does not change when the selectInputs are changed.</p>
  
  <p>As a test, I have tried including this in my serve, coupled with a corresponding dataTableOutput() in my ui:</p>
  
  <pre><code>             output$test1 &lt;- DT::renderDataTable({
                 test()
               })
  </code></pre>
  
  <p>test1 behaves as expected if and only if the second sapply is commented out inside of renderDataTable. If it is not commented out, both tables have a column of unresponsive 21s.</p>
  
  <p>This has been driving me batty all day, so any thoughts would improve my life greatly!</p>