javascript - 两列或多列上 DT::table 中的闪亮合并单元格
问题描述
类似于这个问题:Shiny: Merge cells in DT::datatable
我想知道是否有办法合并两列或更多列。在下面的示例中,仅合并了第 1 列中的重复行,如果我还想合并每个部分中第 5 列中的重复行怎么办。例如,在表格的图像中,我希望合并 Petal.Width 中的 0.2,以及 Petal.Width 中的 1.5。那可能吗?
library(shiny)
library(DT)
dat <- iris[c(1,2,3,51,52,53,101,102,103), c(5,1,2,3,4)]
ui <- fluidPage(
DTOutput("table")
)
server <- function(input, output){
output[["table"]] <- renderDT({
dtable <- datatable(dat, rownames = FALSE,
options = list(
rowsGroup = list(0) # merge cells of column 1
))
path <- "U:/Data/shiny/DT/www" # folder containing dataTables.rowsGroup.js
dep <- htmltools::htmlDependency(
"RowsGroup", "2.0.0",
path, script = "dataTables.rowsGroup.js")
dtable$dependencies <- c(dtable$dependencies, list(dep))
dtable
})
}
shinyApp(ui, server)
解决方案
推荐阅读
- angularjs - angular-ui-router:没有 URL 但有工作回导航的状态
- algorithm - 屏蔽电池劣化的时间总和
- java - 无法在 Wildfly 12.0 中的线程内注入 HttpServletRequest
- airflow - Apache Airflow:气流 initdb 抛出 ModuleNotFoundError:没有名为 'werkzeug.wrappers.json' 的模块;'werkzeug.wrappers' 不是包错误
- c# - 当我们按 date_range 选择 DATA 时如何获取 last_date 余额记录
- python - 将列中的字符串模式更改为列表
- node.js - nodejs express 在索引路由上给出 404 错误
- python - 在 python3.7 中编译的模块与在其他 python3 子版本中编译的相同模块之间有区别吗?
- firebase - Flutter:在 null 上调用了方法“[]”。流提供者
- sql - 获取两个表中不常见的名称列值列表?