Browse Source

Add data-card-visible column option

Dennis Hernández 10 years ago
parent
commit
d6345b7b1b
2 changed files with 15 additions and 12 deletions
  1. 7 0
      docs/_i18n/en/documentation/column-options.md
  2. 8 12
      src/bootstrap-table.js

+ 7 - 0
docs/_i18n/en/documentation/column-options.md

@@ -112,6 +112,13 @@ The column options is defined in `jQuery.fn.bootstrapTable.columnDefaults`.
         <td>False to hide the columns item.</td>
     </tr>
     <tr>
+        <td>card view visible</td>
+        <td>data-card-visible</td>
+        <td>Boolean</td>
+        <td>true</td>
+        <td>False to hide the columns item in card view mode.</td>
+    </tr>
+	<tr>
         <td>switchable</td>
         <td>data-switchable</td>
         <td>Boolean</td>

+ 8 - 12
src/bootstrap-table.js

@@ -444,10 +444,8 @@
                 return;
             }
 
-            if (that.options.cardView) {
-                if (!column.cardVisible) {
-                    return;
-                }
+            if (that.options.cardView && (!column.cardVisible)) {
+                return;
             }
 
             halign = sprintf('text-align: %s; ', column.halign ? column.halign : column.align);
@@ -553,10 +551,8 @@
                 return;
             }
 
-            if (that.options.cardView) {
-                if (!column.cardVisible) {
-                    return;
-                }
+            if (that.options.cardView && (!column.cardVisible)) {
+                return;
             }
 
             falign = sprintf('text-align: %s; ', column.falign ? column.falign : column.align);
@@ -765,10 +761,8 @@
                     return;
                 }
 
-                if (that.options.cardView) {
-                    if (!column.cardVisible) {
-                        return;
-                    }
+                if (that.options.cardView && (!column.cardVisible)) {
+                    return;
                 }
 
                 var checked = column.visible ? ' checked="checked"' : '';
@@ -806,6 +800,7 @@
                 .off('click').on('click', function () {
                     that.options.cardView = !that.options.cardView;
                     that.initHeader();
+                    that.initToolbar();
                     that.initBody();
                 });
         }
@@ -1849,6 +1844,7 @@
     BootstrapTable.prototype.toggleView = function () {
         this.options.cardView = !this.options.cardView;
         this.initHeader();
+        this.initToolbar();
         this.initBody();
     };