Browse Source

Fix #32: add minimunCountColumns option.

zhixin 11 years ago
parent
commit
3249004088
2 changed files with 8 additions and 2 deletions
  1. 1 0
      docs/examples.html
  2. 7 2
      src/bootstrap-table.js

+ 1 - 0
docs/examples.html

@@ -692,6 +692,7 @@
                                 pageList: [10, 25, 50, 100, 200],
                                 search: true,
                                 showColumns: true,
+                                minimunCountColumns: 2,
                                 columns: [{
                                     field: 'state',
                                     checkbox: true

+ 7 - 2
src/bootstrap-table.js

@@ -80,6 +80,7 @@
         selectItemName: 'btSelectItem',
         showHeader: true,
         showColumns: false,
+        minimunCountColumns: 1,
         idField: undefined,
         cardView: false,
         clickToSelect: false,
@@ -378,14 +379,18 @@
 
             this.$toolbar.append(html.join(''));
 
-            $keepOpen = this.$toolbar.find('.keep-open label');
+            $keepOpen = this.$toolbar.find('.keep-open li');
             $keepOpen.off('click').on('click', function(event) {
                 event.stopPropagation();
-                var $this = $(this).find('input');
+                var $this = $(this).find('input'),
+                    $items = $keepOpen.find('input').prop('disabled', false);
 
                 that.options.columns[$this.val()].visible = $this.prop('checked');
                 that.initHeader();
                 that.initBody();
+                if ($items.filter(':checked').length <= that.options.minimunCountColumns) {
+                    $items.filter(':checked').prop('disabled', true);
+                }
             });
         }