Browse Source

Merge pull request #40 from wenzhixin/master

Update my repo
Dennis Hernández 10 years ago
parent
commit
f884902ad1

+ 6 - 1
docs/_i18n/en/documentation/methods.md

@@ -26,7 +26,12 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
     <tr>
     <tr>
         <td>getSelections</td>
         <td>getSelections</td>
         <td>none</td>
         <td>none</td>
-        <td>Return all selected rows, when no record selected, am empty array will return.</td>
+        <td>Return selected rows, when no record selected, am empty array will return.</td>
+    </tr>
+    <tr>
+        <td>getAllSelections</td>
+        <td>none</td>
+        <td>Return selected rows in all pages, when no record selected, am empty array will return.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>getData</td>
         <td>getData</td>

+ 4 - 0
src/bootstrap-table.css

@@ -136,6 +136,10 @@
     margin-bottom: 10px;
     margin-bottom: 10px;
 }
 }
 
 
+.fixed-table-pagination div.pagination .pagination {
+    margin: 0;
+}
+
 .fixed-table-pagination .pagination a {
 .fixed-table-pagination .pagination a {
     padding: 6px 12px;
     padding: 6px 12px;
     line-height: 1.428571429;
     line-height: 1.428571429;

+ 24 - 3
src/bootstrap-table.js

@@ -444,15 +444,16 @@
         this.$el.find('tbody tr').each(function () {
         this.$el.find('tbody tr').each(function () {
             var row = {};
             var row = {};
 
 
-            // save tr's id and class
+            // save tr's id, class and data-* attributes
             row._id = $(this).attr('id');
             row._id = $(this).attr('id');
             row._class = $(this).attr('class');
             row._class = $(this).attr('class');
+            row._data = $(this).data();
 
 
             $(this).find('td').each(function (i) {
             $(this).find('td').each(function (i) {
                 var field = that.options.columns[i].field;
                 var field = that.options.columns[i].field;
 
 
                 row[field] = $(this).html();
                 row[field] = $(this).html();
-                // save td's id and class
+                // save td's id, class and data-* attributes
                 row['_' + field + '_id'] = $(this).attr('id');
                 row['_' + field + '_id'] = $(this).attr('id');
                 row['_' + field + '_class'] = $(this).attr('class');
                 row['_' + field + '_class'] = $(this).attr('class');
                 row['_' + field + '_data'] = $(this).data();
                 row['_' + field + '_data'] = $(this).data();
@@ -1164,6 +1165,7 @@
                 item = data[i],
                 item = data[i],
                 style = {},
                 style = {},
                 csses = [],
                 csses = [],
+                data_ = '',
                 attributes = {},
                 attributes = {},
                 htmlAttributes = [];
                 htmlAttributes = [];
 
 
@@ -1184,12 +1186,23 @@
                 }
                 }
             }
             }
 
 
+            if (item._data && !$.isEmptyObject(item._data)) {
+                $.each(item._data, function (k, v) {
+                    // ignore data-index
+                    if (k === 'index') {
+                        return;
+                    }
+                    data_ += sprintf(' data-%s="%s"', k, v);
+                });
+            }
+
             html.push('<tr',
             html.push('<tr',
                 sprintf(' %s', htmlAttributes.join(' ')),
                 sprintf(' %s', htmlAttributes.join(' ')),
                 sprintf(' id="%s"', $.isArray(item) ? undefined : item._id),
                 sprintf(' id="%s"', $.isArray(item) ? undefined : item._id),
                 sprintf(' class="%s"', style.classes || ($.isArray(item) ? undefined : item._class)),
                 sprintf(' class="%s"', style.classes || ($.isArray(item) ? undefined : item._class)),
                 sprintf(' data-index="%s"', i),
                 sprintf(' data-index="%s"', i),
                 sprintf(' data-unique-id="%s"', item[this.options.uniqueId]),
                 sprintf(' data-unique-id="%s"', item[this.options.uniqueId]),
+                sprintf('%s', data_),
                 '>'
                 '>'
             );
             );
 
 
@@ -1855,6 +1868,14 @@
         });
         });
     };
     };
 
 
+    BootstrapTable.prototype.getAllSelections = function () {
+        var that = this;
+
+        return $.grep(this.options.data, function (row) {
+            return row[that.header.stateField];
+        });
+    };
+
     BootstrapTable.prototype.checkAll = function () {
     BootstrapTable.prototype.checkAll = function () {
         this.checkAll_(true);
         this.checkAll_(true);
     };
     };
@@ -2032,7 +2053,7 @@
 
 
     var allowedMethods = [
     var allowedMethods = [
         'getOptions',
         'getOptions',
-        'getSelections', 'getData',
+        'getSelections', 'getAllSelections', 'getData',
         'load', 'append', 'prepend', 'remove',
         'load', 'append', 'prepend', 'remove',
         'insertRow', 'updateRow',
         'insertRow', 'updateRow',
         'showRow', 'hideRow', 'getRowsHidden',
         'showRow', 'hideRow', 'getRowsHidden',

+ 8 - 3
src/extensions/resizable/bootstrap-table-resizable.js

@@ -54,11 +54,16 @@
     };
     };
 
 
     BootstrapTable.prototype.resetView = function () {
     BootstrapTable.prototype.resetView = function () {
-        if (this.options.resizable) {
-            initResizable(this);
-        }
+        var that = this;
 
 
         _resetView.apply(this, Array.prototype.slice.apply(arguments));
         _resetView.apply(this, Array.prototype.slice.apply(arguments));
+
+        if (this.options.resizable) {
+            // because in fitHeader function, we use setTimeout(func, 100);
+            setTimeout(function () {
+                initResizable(that);
+            }, 100);
+        }
     };
     };
 
 
     BootstrapTable.prototype.onResize = function (e) {
     BootstrapTable.prototype.onResize = function (e) {