浏览代码

Merge pull request #5804 from fournm/patch-1

Fix for #5803 (multiple-sort and hide-show column interaction with no default sortPriority bug)
文翼 4 年之前
父节点
当前提交
5dc4aa95c2
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      src/extensions/multiple-sort/bootstrap-table-multiple-sort.js

+ 7 - 4
src/extensions/multiple-sort/bootstrap-table-multiple-sort.js

@@ -656,13 +656,16 @@ BootstrapTable.prototype.initToolbar = function (...args) {
     })
 
     this.$el.on('column-switch.bs.table', (field, checked) => {
-      for (let i = 0; i < that.options.sortPriority.length; i++) {
-        if (that.options.sortPriority[i].sortName === checked) {
-          that.options.sortPriority.splice(i, 1)
+      if (that.options.sortPriority !== null && that.options.sortPriority.length > 0) {
+        for (let i = 0; i < that.options.sortPriority.length; i++) {
+          if (that.options.sortPriority[i].sortName === checked) {
+            that.options.sortPriority.splice(i, 1)
+          }
         }
+
+        that.assignSortableArrows()
       }
 
-      that.assignSortableArrows()
       that.$sortModal.remove()
       showSortModal(that)
     })