浏览代码

Merge pull request #6078 from wenzhixin/fix/bug-6007

Fixed the toggle column bug with the cookie extension
Dustin Utecht 3 年之前
父节点
当前提交
a86c8de7b5
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      src/extensions/cookie/bootstrap-table-cookie.js

+ 6 - 4
src/extensions/cookie/bootstrap-table-cookie.js

@@ -481,7 +481,11 @@ $.BootstrapTable = class extends $.BootstrapTable {
 
 
     if (columnsCookie) {
     if (columnsCookie) {
       for (const column of this.columns) {
       for (const column of this.columns) {
-        const filteredColumns = columnsCookie.filter(columnField => {
+        if (!column.switchable) {
+          continue
+        }
+
+        column.visible = columnsCookie.filter(columnField => {
           if (this.isSelectionColumn(column)) {
           if (this.isSelectionColumn(column)) {
             return true
             return true
           }
           }
@@ -495,9 +499,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
           }
           }
 
 
           return columnField === column.field
           return columnField === column.field
-        })
-
-        column.visible = (filteredColumns.length > 0 || !column.switchable) && column.visible
+        }).length > 0
       }
       }
     }
     }
   }
   }