Browse Source

Fixed search bug in hidden columns

zhixin 6 years ago
parent
commit
8e6b9d5fab
1 changed files with 8 additions and 4 deletions
  1. 8 4
      src/bootstrap-table.js

+ 8 - 4
src/bootstrap-table.js

@@ -237,10 +237,6 @@ class BootstrapTable {
       }
 
       columns.forEach((column, j) => {
-        if (!column.visible) {
-          return
-        }
-
         const class_ = Utils.sprintf(' class="%s"', column['class'])
         const unitWidth = column.widthUnit
         const width = parseFloat(column.width)
@@ -252,6 +248,10 @@ class BootstrapTable {
           ? (!column.showSelectTitle ? '36px' : undefined)
           : (width ? width + unitWidth : undefined))
 
+        if (typeof column.fieldIndex === 'undefined' && !column.visible) {
+          return
+        }
+
         if (typeof column.fieldIndex !== 'undefined') {
           this.header.fields[column.fieldIndex] = column.field
           this.header.styles[column.fieldIndex] = align + style
@@ -264,6 +264,10 @@ class BootstrapTable {
           this.header.cellStyles[column.fieldIndex] = column.cellStyle
           this.header.searchables[column.fieldIndex] = column.searchable
 
+          if (!column.visible) {
+            return
+          }
+
           if (this.options.cardView && (!column.cardVisible)) {
             return
           }