首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Bootstrap-Table:展开未隐藏的行

Bootstrap-Table:展开未隐藏的行
EN

Stack Overflow用户
提问于 2021-05-20 23:22:00
回答 1查看 207关注 0票数 0

我设置了过滤器来隐藏引导表中的某些行。我还实现了"expandAllRows“方法来显示所有细节视图;然而,这个方法将展开所有行,包括那些被我的过滤器隐藏的行。

如何修改bootstrap-table.min.js以仅显示可见行的详细视图?

我认为我需要修改bootstrap-table.min.js中的代码行,但不确定如何修改:

代码语言:javascript
复制
...{key:"expandAllRows",value:function(){for(var t=this.$body.find("> tr[data-index][data-has-detail-view]"),e=0;e<t.length;e++)this.expandRow(i.default(t[e[).data("index"))}...

我使用bootstrap-table button方法来添加用于展开和折叠行的自定义按钮。如下所示:

代码语言:javascript
复制
function buttons() {
    var $table = $('#table')
    var $expand = $('#expand')
    var $collapse = $('#collapse')

    return {
        btnExpand: {
            text: 'Expand All Rows',
            icon: 'fas fa-angle-double-down',
            event: function() {
                $table.bootstrapTable('expandAllRows')
            },
            attributes: {
                title: 'Expand all rows'
            }
        },
        btnCollapse: {
            text: 'Collapse All Rows',
            icon: 'fas fa-angle-double-up',
            event: function() {
                $table.bootstrapTable('collapseAllRows')
            },
            attributes: {
                title: 'Collapse all rows'
            }
        }
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-21 02:29:05

与其修改bootstraps的函数,不如在过滤时通过重命名属性来绕过它们。像这样的东西

代码语言:javascript
复制
function filter(keyword) {
  // your current filter logic, which hides the rows that don't match
  // in this example, you have hidden them with the class 'hidden-row' 
  let hiddenRows=$("tr.hidden-row[data-has-detail-view='true']");
  hiddenRows.each( function() {
     $(this).attr({
        'data-has-detail-view-hidden': 'true'
      })
      .removeAttr('data-has-detail-view');
  })
}

function clearFilters() {
// your logic, then
      let hiddenRows=$("tr.hidden-row[data-has-detail-view-hidden='true']");
      hiddenRows.each( function() {
         $(this).attr({
            'data-has-detail-view': 'true'
          })
          .removeAttr('data-has-detail-view-hidden')
          .removeClass('hidden-row');
      })
 }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67623364

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档