我正在尝试将总计添加到数据表页脚。使用来自不同来源的代码,我使用 Shiny 编写了以下应用程序。问题是,当我运行它时,会出现以下消息:
“加工 ...”
并永远留在那里。
我的猜测是 JS() 代码,但无法调试。
library(shiny)
library(DT)
library(htmltools)
ui <- fluidPage(
fluidRow(
column(9, DT::dataTableOutput('withtotal'))
)
)
server <- function(input, output, session) {
# server-side processing
mtcars2 = mtcars[, 1:8]
#sketch <- htmltools::withTags(table(tableHeader(mtcars2), tableFooter(mtcars2)))
sketch = htmltools::withTags(table(tableFooter(c("",0,0,0,0,0,0,0))))
opts <- list( footerCallback = JS("function ( row, data, start, end, display ) {",
"var api = this.api();",
"var intVal = function ( i ) {",
"return typeof i === 'string' ?",
"i.replace(/[\\$,]/g, '')*1 :",
"typeof i === 'number' ?", …Run Code Online (Sandbox Code Playgroud)