ソースを参照

Collapsing detail view on collapsing groups (#5340)

* Collapsing detail view on collapsing groups

* Reuse variables

Co-authored-by: Dennis Hernández <dennishernandezvargas@gmail.com>
Dustin Utecht 5 年 前
コミット
ca5fcfa5c4
1 ファイル変更8 行追加3 行削除
  1. 8 3
      src/extensions/group-by-v2/bootstrap-table-group-by.js

+ 8 - 3
src/extensions/group-by-v2/bootstrap-table-group-by.js

@@ -190,9 +190,14 @@ BootstrapTable.prototype.initBody = function (...args) {
     if (this.options.groupByToggle) {
       this.$container.off('click', '.groupBy')
         .on('click', '.groupBy', function () {
-          $(this).toggleClass('expanded collapsed')
-          $(this).find('span').toggleClass(`${that.options.icons.collapseGroup} ${that.options.icons.expandGroup}`)
-          that.$body.find(`tr[data-parent-index=${$(this).closest('tr').data('group-index')}]`).toggleClass('hidden')
+          const $this = $(this)
+          const groupIndex = $this.closest('tr').data('group-index')
+          const $groupRows = that.$body.find(`tr[data-parent-index=${groupIndex}]`)
+
+          $this.toggleClass('expanded collapsed')
+          $this.find('span').toggleClass(`${that.options.icons.collapseGroup} ${that.options.icons.expandGroup}`)
+          $groupRows.toggleClass('hidden')
+          $groupRows.each((i, element) => that.collapseRow($(element).data('index')))
         })
     }