Browse Source

GetData option to get the current page

Dennis Hernández 10 years ago
parent
commit
d81170ff6a
2 changed files with 8 additions and 4 deletions
  1. 6 2
      src/bootstrap-table.js
  2. 2 2
      src/extensions/flatJSON/bootstrap-table-flatJSON.js

+ 6 - 2
src/bootstrap-table.js

@@ -1677,10 +1677,14 @@
         $tableContainer.css('padding-bottom', padding + 'px');
     };
 
-    BootstrapTable.prototype.getData = function () {
+    BootstrapTable.prototype.getData = function (useCurrentPage) {
         return (this.searchText
             || !$.isEmptyObject(this.filterColumns)
-            || !$.isEmptyObject(this.filterColumnsPartial)) ? this.data : this.options.data;
+            || !$.isEmptyObject(this.filterColumnsPartial)) ?
+            (useCurrentPage ? this.data.slice(this.pageFrom -1, this.pageTo)
+                : this.data) :
+            (useCurrentPage ? this.options.data.slice(this.pageFrom - 1, this.pageTo)
+                : this.options.data);
     };
 
     BootstrapTable.prototype.load = function (data) {

+ 2 - 2
src/extensions/flatJSON/bootstrap-table-flatJSON.js

@@ -44,8 +44,6 @@
 
     BootstrapTable.prototype.initData = function () {
 
-        _initData.apply(this, Array.prototype.slice.apply(arguments));
-
         //If the flat is true
         if (this.options.flat) {
             this.options.data = sd.flatHelper(this.options.data);
@@ -53,6 +51,8 @@
         if (this.options.sidePagination === 'server') {
             this.data = this.options.data;
         }
+
+        _initData.apply(this, Array.prototype.slice.apply(arguments));
     };
 
     //Main functions