【问题标题】:Deleting DT::datatable's header results in 'no matching records found' when using renderDT() in a shiny app在闪亮的应用程序中使用 renderDT() 时,删除 DT::datatable 的标头会导致“找不到匹配的记录”
【发布时间】:2020-05-25 00:29:24
【问题描述】:

当在renderDT() 中使用时,尝试从 DT::datatable 中删除标题会导致 'No matching records found'。为什么会这样?我该如何解决?

library(shiny)
library(shinydashboard)
library(DT)
ui <- dashboardPage(
    dashboardHeader(title = "Dynamic sidebar"),
    dashboardSidebar(
    ),
    dashboardBody(
        DT::dataTableOutput("t")
    )
)

server <- function(input, output) {
    output$t<-renderDT(datatable(head(iris),colnames = ""))
}

shinyApp(ui, server)

【问题讨论】:

    标签: r shiny dt


    【解决方案1】:

    此问题的简单解决方案是将renderDT() 中的server 参数设置为FALSE。然而,这个论点的描述说:

    如果为 FALSE,则立即将整个数据帧发送到浏览器。强烈建议用于中大型数据帧,这可能会导致浏览器变慢或崩溃。

    如果这对你没有问题,试试这个:

    library(DT)
    library(shiny)
    library(shinydashboard)
    ui <- dashboardPage(
      dashboardHeader(title = "Dynamic sidebar"),
      dashboardSidebar(
      ),
      dashboardBody(
        DT::dataTableOutput("t")
      )
    )
    debugonce(renderDT)
    server <- function(input, output) {
      output$t <- renderDT(datatable(head(iris),colnames = ""), server = FALSE)
    }
    
    shinyApp(ui, server)
    

    【讨论】:

      猜你喜欢
      • 2020-01-13
      • 2022-01-08
      • 2021-10-21
      • 1970-01-01
      • 1970-01-01
      • 2018-11-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-27
      相关资源
      最近更新 更多