title: Radio buttons in a reactive table
body: <p>I'm trying to create a reactive datatable with embedded radio buttons in Shiny.</p>
  <p>The example below is based on <a href="https://yihui.shinyapps.io/DT-radio/" rel="nofollow noreferrer">https://yihui.shinyapps.io/DT-radio/</a> but instead of a static table I use a reactive, since I'd like to dynamically add/remove rows from the table. The app works as expected before changing the number of rows. After changing the number of rows, the table is updated but the radio button values do not update. The one exception is the newly added row which does get updated.</p>
  <p>N.B. I noticed when using the inspect element tool that &quot;shiny-bound-input&quot; is dropped from the table row class after changing the rows, except for newly added rows.</p>
  <p>Does the callback function need to be updated, or is there something wrong in how I've set up the app? Any help would be appreciated.</p>
  <p>Session info:</p>
  <pre><code>R version 4.0.2 (2020-06-22)
  Platform: x86_64-w64-mingw32/x64 (64-bit)
  Running under: Windows 10 x64 (build 19044)
  
  Matrix products: default
  
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     
  
  other attached packages:
  [1] DT_0.20        testthat_3.1.0 shiny_1.7.1   
  </code></pre>
  <p>App</p>
  <pre><code>library(shiny)
  library(DT)
  
  shinyApp(
    ui = fluidPage(
      title = 'Radio buttons in a table',
      numericInput(&quot;n_row&quot;, &quot;Number of rows&quot;, value = 3, min = 1, max = 10),
      DT::dataTableOutput('foo'),
      verbatimTextOutput('sel')
    ),
    
    server = function(input, output, session) {
      
      mr = reactive({
        
        m &lt;-
        matrix(
          as.character(1:3), nrow = input$n_row, ncol = 3, byrow = TRUE,
          dimnames = list(seq(input$n_row), LETTERS[1:3])
        )
        for (i in seq_len(nrow(m))) {
          m[i, ] = sprintf(
            '&lt;input type=&quot;radio&quot; name=&quot;%s&quot; value=&quot;%s&quot;/&gt;',
            seq(input$n_row)[i], m[i, ]
          )
        }
        
        m
      })
  
      output$foo = DT::renderDataTable(
        
        mr(), 
        
        escape = FALSE, selection = 'none', server = FALSE,
        options = list(dom = 't', paging = FALSE, ordering = FALSE),
        callback = JS(&quot;table.rows().every(function(i, tab, row) {
            var $this = $(this.node());
            $this.attr('id', this.data()[0]);
            $this.addClass('shiny-input-radiogroup');
          });
          Shiny.unbindAll(table.table().node());
          Shiny.bindAll(table.table().node());&quot;)
      )
      output$sel = renderPrint({
        str(sapply(as.character(seq(input$n_row)), function(i) input[[i]]))
      })
      
    }
  )
  </code></pre>