Search code examples
rshinydt

DT:datatableAjax stuck at "Processing..." Server=False works fine


I cannot figure out what my issue is. The code bellow does not work and the datatable is stuck displaying Processing... with the browser console warning:

"Failed to load resource: the server responded with a status of 400 (Bad Request)"

On the server:

     output$dt <- DT::renderDataTable({
        dtdf <- data1()[,-13:-14] %>%
          mutate(Action = paste('<a class="go-map" href="" data-lat="', Latitude, '" data-long="', Longitude, '" data-zip="', ID, '"><i class="glyphicon glyphicon-pushpin"></i></a>', sep=""))
        action <- DT::dataTableAjax(session, dtdf)
        DT::datatable(dtdf, extensions = 'Buttons', options = list(ajax = list(url = action), dom = 'Bfrtip', buttons = c('excel', 'pdf'), pageLength = 25, columnDefs = list(list(className = 'dt-center', targets ="_all"))), escape = FALSE)
      })

On the ui:

 DT::dataTableOutput("dt")

Simply changing to the option server=FALSE, like below, works as expected. However, my dataset is too large to disable server-side processing.

  output$dt <- DT::renderDataTable({
    dtdf <- data1()[,-13:-14] %>%
      mutate(Action = paste('<a class="go-map" href="" data-lat="', Latitude, '" data-long="', Longitude, '" data-zip="', ID, '"><i class="glyphicon glyphicon-pushpin"></i></a>', sep=""))
    action <- DT::dataTableAjax(session, dtdf)
    DT::datatable(dtdf, extensions = 'Buttons', options = list(ajax = list(url = action), dom = 'Bfrtip', buttons = c('excel', 'pdf'), pageLength = 25, columnDefs = list(list(className = 'dt-center', targets ="_all"))), escape = FALSE)
  }, server = FALSE)

What am I doing wrong?


Solution

  • For anyone having similar issues, try installing the latest version!

    A fresh install of DT with devtools::install_github('rstudio/DT') seems to have solved it for me!