Browse Source

Improved functions showColumn and hideColumn, add ability to show/hide
multiple at once

Dustin Utecht 6 years ago
parent
commit
015bb15981
2 changed files with 12 additions and 4 deletions
  1. 4 2
      site/docs/api/methods.md
  2. 8 2
      src/bootstrap-table.js

+ 4 - 2
site/docs/api/methods.md

@@ -351,7 +351,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
 - **Detail:**
 
-  Show the specified `field` column.
+  Show the specified `field` column.   
+  The parameter can be a string or a array of fields.
 
 ## hideColumn
 
@@ -359,7 +360,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
 - **Detail:**
 
-  Hide the specified `field` column.
+  Hide the specified `field` column.   
+  The parameter can be a string or a array of fields.
 
 ## getHiddenColumns
 

+ 8 - 2
src/bootstrap-table.js

@@ -3080,11 +3080,17 @@
     }
 
     showColumn (field) {
-      this.toggleColumn(this.fieldsColumnsIndex[field], true, true)
+      const fields = Array.isArray(field) ? field : [field]
+      fields.forEach( (field) => {
+        this.toggleColumn(this.fieldsColumnsIndex[field], true, true)
+      })
     }
 
     hideColumn (field) {
-      this.toggleColumn(this.fieldsColumnsIndex[field], false, true)
+      const fields = Array.isArray(field) ? field : [field]
+      fields.forEach( (field) => {
+        this.toggleColumn(this.fieldsColumnsIndex[field], false, true)
+      })
     }
 
     getHiddenColumns () {