我所描述的可以使用 SearchPanes 扩展来完成。您可以在与 rowGroup 目标相同的列上选择 searchPanes 目标。
您还可以将 searchPanes 设置为按钮。
我的代码示例,在 renderDT 中使用:
output$tbl <- renderDT({
datatable(data,
rownames = FALSE,
caption = 'Some caption',
extensions = c('ColReorder', 'RowGroup', "Buttons",
"Select", "SearchPanes"),
options = list(#DOM options
dom = "Bfrtip",
#Rowgroup options
rowGroup = list(dataSrc = c(0,2)),
#Buttons options
stateSave = TRUE,
buttons = c('colvis', 'csv', 'excel', 'searchPanes'),
#ColReorder options
colReorder = TRUE,
#SearchPanes options
columnDefs = list(
list(searchPanes = list(show = FALSE), targets = 1:7)),
selection = 'none',
#Overige options
paging = FALSE)
)}, server = FALSE)
也感谢 Matt Herman 的博文:https://mattherman.info/blog/dt_searchpanes/