I am trying to create 4 radio buttons against each row in an R Shiny renderDataTable. I did some research and found this code working fine for my purposes:
  output$featureset = DT::renderDataTable(
  m, escape = FALSE, selection = 'none', server = FALSE,
  options = list(dom = 't', paging = FALSE, ordering = FALSE)
  ,
  callback = JS("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());"
  )
)
But, before creating this dynamic dataset and generating these radio buttons, I need to create a spark connection. Connection creation and dynamic loading of the data takes a bit of time, so I thought I'd put them at a button click. So, I introduced a button and created a connection, and loaded the data behind that button click(eventReactive).
Now, my problem is that I am not sure how I make 'renderDataTable' dependent on that button click. I tried putting in an if condition like so:
  output$featureset = DT::renderDataTable({
    if (is.null(conn_spark())) {print('commmon')}
      dataset
    },escape = FALSE, selection = 'none', server = FALSE, options = list(dom = 't', paging = FALSE, ordering = FALSE),
                      callback = JS("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());"
                      )
  ) 
But, for some reason its not working. I don't see anything created. I'd appreciate any help. Thanks.
Please feel free to let me know if there's anything that can help but I haven't included in my question. I'd be glad to do so.
