【问题标题】:Tabulator Show/Hide Groups制表符显示/隐藏组
【发布时间】:2019-07-31 00:42:20
【问题描述】:

有没有办法显示/隐藏 GroupBy?我喜欢折叠或展开组的选项,但最好将折叠/展开/不分组作为 3 个选项。

如何添加一个按钮来显示/隐藏组?我将在哪里放置代码来执行这样的功能?

【问题讨论】:

    标签: tabulator


    【解决方案1】:

    您可以使用此代码:

    $("#show-all-group").click(function(){
        table.setGroupStartOpen(true);
    });
    

    文档:http://tabulator.info/docs/4.2/group

    【讨论】:

      【解决方案2】:

      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())
      });
      

      请注意,当您有很多行组时,展开/折叠组的性能可能会很差。

      更多详情请见http://tabulator.info/docs/4.4/group

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-13
        • 2021-08-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多