Browse Source

Merge pull request #307 from ice5050/feature/PrevNextPageMethod

Feature/prev next page method
文翼 11 years ago
parent
commit
75853eddac
2 changed files with 22 additions and 1 deletions
  1. 10 0
      docs/_includes/documentation/methods.md
  2. 12 1
      src/bootstrap-table.js

+ 10 - 0
docs/_includes/documentation/methods.md

@@ -121,5 +121,15 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <td>params</td>
         <td>(Can use only in client-side)Filter data in table, eg. you can filter <code>{age: 10}</code> to show the data only age is equal to 10.</td>
     </tr>
+    <tr>
+        <td>prevPage</td>
+        <td>none</td>
+        <td>Go to previous page.</td>
+    </tr>
+    <tr>
+        <td>nextPage</td>
+        <td>none</td>
+        <td>Go to next page.</td>
+    </tr>
     </tbody>
 </table>

+ 12 - 1
src/bootstrap-table.js

@@ -1484,6 +1484,16 @@
         }
     };
 
+    BootstrapTable.prototype.prevPage = function () {
+        this.options.pageNumber > 1 ? this.options.pageNumber-- : null;
+        this.updatePagination();
+    };
+
+    BootstrapTable.prototype.nextPage = function () {
+        this.options.pageNumber < this.options.pageSize ? this.options.pageNumber++ : null;
+        this.updatePagination();
+    };
+
     // BOOTSTRAP TABLE PLUGIN DEFINITION
     // =======================
 
@@ -1499,7 +1509,8 @@
         'showLoading', 'hideLoading',
         'showColumn', 'hideColumn',
         'filterBy',
-        'scrollTo'
+        'scrollTo',
+        'prevPage', 'nextPage'
     ];
 
     $.fn.bootstrapTable = function (option, _relatedTarget) {