首页 > 解决方案 > DT:datatableAjax 卡在“处理中...” Server=False 工作正常

问题描述

我无法弄清楚我的问题是什么。下面的代码不起作用,并且数据表卡Processing...在浏览器控制台警告中显示:

“加载资源失败:服务器响应状态为 400(错误请求)”

在服务器上:

     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)
      })

在用户界面上:

 DT::dataTableOutput("dt")

只需更改为 option server=FALSE,如下所示,即可按预期工作。但是,我的数据集太大而无法禁用服务器端处理。

  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)

我究竟做错了什么?

标签: rshinydatatables

解决方案


对于有类似问题的任何人,请尝试安装最新版本!

全新安装的 DTdevtools::install_github('rstudio/DT')似乎为我解决了这个问题!


推荐阅读