【发布时间】:2019-07-31 00:42:20
【问题描述】:
有没有办法显示/隐藏 GroupBy?我喜欢折叠或展开组的选项,但最好将折叠/展开/不分组作为 3 个选项。
如何添加一个按钮来显示/隐藏组?我将在哪里放置代码来执行这样的功能?
【问题讨论】:
标签: tabulator
有没有办法显示/隐藏 GroupBy?我喜欢折叠或展开组的选项,但最好将折叠/展开/不分组作为 3 个选项。
如何添加一个按钮来显示/隐藏组?我将在哪里放置代码来执行这样的功能?
【问题讨论】:
标签: tabulator
您可以使用此代码:
$("#show-all-group").click(function(){
table.setGroupStartOpen(true);
});
【讨论】:
向tabulator.setGroupBy() 传递虚假值或什么都不传递会有效地禁用分组:
var tabulator = new Tabulator({});
var groupBy = tabulator.options.groupBy;
disableGroupButton.addEventListener('click', function() {
tabulator.setGroupBy();
});
enableGroupButton.addEventListener('click', function() {
tabulator.setGroupBy(groupBy);
});
要展开/折叠组,您需要:
expandGroupButton.addEventListener('click', function() {
tabulator.setGroupStartOpen(true)
tabulator.getGroups().forEach(x => x._group.show())
});
collapseGroupButton.addEventListener('click', function() {
tabulator.setGroupStartOpen(false)
tabulator.getGroups().forEach(x => x._group.hide())
});
请注意,当您有很多行组时,展开/折叠组的性能可能会很差。
【讨论】: