ソースを参照

Update maintainSelected option.

zhixin 11 年 前
コミット
ff7baa4e19
1 ファイル変更20 行追加27 行削除
  1. 20 27
      src/bootstrap-table.js

+ 20 - 27
src/bootstrap-table.js

@@ -125,7 +125,7 @@
         toolbar: undefined,
         checkboxHeader: true,
         sortable: true,
-        maintainSelected: true,
+        maintainSelected: false,
 
         rowStyle: function (row, index) {return {};},
 
@@ -546,24 +546,19 @@
         var that = this;
 
         if (this.options.sidePagination !== 'server') {
-            if (this.searchText) {
-                var s = this.searchText && this.searchText.toLowerCase();
-
-                this.data = s ? $.grep(this.options.data, function (item) {
-                    for (var key in item) {
-                        if (that.header.fields.indexOf(key) !== -1 &&
-                            (typeof item[key] === 'string' ||
-                            typeof item[key] === 'number') &&
-                            (item[key] + '').toLowerCase().indexOf(s) !== -1) {
-                            return true;
-                        }
+            var s = this.searchText && this.searchText.toLowerCase();
+
+            this.data = s ? $.grep(this.options.data, function (item) {
+                for (var key in item) {
+                    if (that.header.fields.indexOf(key) !== -1 &&
+                        (typeof item[key] === 'string' ||
+                        typeof item[key] === 'number') &&
+                        (item[key] + '').toLowerCase().indexOf(s) !== -1) {
+                        return true;
                     }
-                    return false;
-                }) : this.options.data;
-            } else {
-                // restore data
-                this.data = this.options.data;
-            }
+                }
+                return false;
+            }) : this.options.data;
         }
     };
 
@@ -743,8 +738,7 @@
     BootstrapTable.prototype.initBody = function (fixedScroll) {
         var that = this,
             html = [],
-            //data = this.getData();
-            data = this.searchText ? this.data : this.options.data;
+            data = this.getData();
 
         this.$body = this.$el.find('tbody');
         if (!this.$body.length) {
@@ -1009,13 +1003,12 @@
 
     BootstrapTable.prototype.resetRows = function () {
         var that = this;
-        if (!that.options.maintainSelected) {
-            $.each(this.data, function (i, row) {
-                that.$selectAll.prop('checked', false);
-                that.$selectItem.prop('checked', false);
-                row[that.header.stateField] = false;
-            });
-        }
+
+        $.each(this.data, function (i, row) {
+            that.$selectAll.prop('checked', false);
+            that.$selectItem.prop('checked', false);
+            row[that.header.stateField] = false;
+        });
     };
 
     BootstrapTable.prototype.trigger = function (name) {