数据表按钮到 show/hide 行组
Datatables Buttons to show/hide RowGroups
我有一个 table 使用行组和 Buttons/Colvis。
与 Colvis 的按钮非常相似,我希望按钮只显示特定的行组。目前我有一个很长的 table 和很多行组。用户通常只希望看到特定的列组,我想防止他们一直向下滚动。
从下面的示例中,假设有一个按钮“行组”可见性,就像 Colvis 中的列可见性一样。
我所描述的可以使用 SearchPanes 扩展来完成。您可以 select 将 searchPanes 定位到与 rowGroup 定位相同的列。
您还可以将搜索窗格设置为按钮。
我的代码示例,在 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 的博客 post:https://mattherman.info/blog/dt_searchpanes/
我有一个 table 使用行组和 Buttons/Colvis。
与 Colvis 的按钮非常相似,我希望按钮只显示特定的行组。目前我有一个很长的 table 和很多行组。用户通常只希望看到特定的列组,我想防止他们一直向下滚动。
从下面的示例中,假设有一个按钮“行组”可见性,就像 Colvis 中的列可见性一样。
我所描述的可以使用 SearchPanes 扩展来完成。您可以 select 将 searchPanes 定位到与 rowGroup 定位相同的列。
您还可以将搜索窗格设置为按钮。
我的代码示例,在 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 的博客 post:https://mattherman.info/blog/dt_searchpanes/