R Shiny DT:DataTables 警告:表 id=DataTables_Table_0 - 无效的 JSON 响应

问题描述 投票:0回答:0

我正在尝试使用 Shiny DT 的“SearchPanes”扩展。看来我必须使用“server=FALSE”来使“SearchPanes”工作,否则,它不会在“SearchPanes”中显示任何数据。

但是当设置“server=FALSE”时,如果编辑表格的任何单元格都会引发以下错误。

“DataTables 警告:表 id=DataTables_Table_0 - 无效的 JSON 响应。有关此错误的更多信息,请参阅 http://datatables.net/tn/1”

请帮忙如何让它工作?提前致谢!

library(shiny)
library(DT)

## UI
ui = fluidPage(
  DT::DTOutput('tbl')
)


## SERVER
server = function(input, output) {
  #
  df <- iris 
  output$tbl <- DT::renderDataTable(
    {  DT::datatable(
      df,
      editable = TRUE,
      extensions = c('SearchPanes','Select'),
      selection = 'none',
      options = list(
        dom = 'PBfrtip', 
        columnDefs = list(list(searchPanes = list(show = FALSE), targets=1:4))
        )
    )
    }, server = FALSE)
  
  
  observeEvent(input$tbl_cell_edit, {
    df[input$tbl_cell_edit$row, input$tbl_cell_edit$col] <<- input$tbl_cell_edit$value
  })
  
  proxy <- dataTableProxy("tbl")
  observeEvent(input$tbl_cell_edit,{
    df <<- editData(df, input$tbl_cell_edit, proxy)
    })
}

## App
shinyApp(ui, server)
r shiny dt
© www.soinside.com 2019 - 2024. All rights reserved.