Browse Source

Merge pull request #12 from wenzhixin/master

Update my repo
Dennis Hernández 11 years ago
parent
commit
c2ebe85648

+ 10 - 0
docs/_i18n/en/documentation/methods.md

@@ -18,6 +18,11 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
     </thead>
     <tbody>
     <tr>
+        <td>getOptions</td>
+        <td>none</td>
+        <td>Return the options object.</td>
+    </tr>
+    <tr>
         <td>getSelections</td>
         <td>none</td>
         <td>Return all selected rows, when no record selected, am empty array will return.</td>
@@ -147,6 +152,11 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <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>selectPage</td>
+        <td>page</td>
+        <td>Go to the a specified page.</td>
+    </tr>
+    <tr>
         <td>prevPage</td>
         <td>none</td>
         <td>Go to previous page.</td>

+ 7 - 0
docs/_i18n/en/documentation/table-options.md

@@ -267,6 +267,13 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         </td>
     </tr>
     <tr>
+        <td>showPaginationSwitch</td>
+        <td>data-show-pagination-switch</td>
+        <td>Boolean</td>
+        <td>false</td>
+        <td>True to show the pagination switch button.</td>
+    </tr>
+    <tr>
         <td>minimumCountColumns</td>
         <td>data-minimum-count-columns</td>
         <td>Number</td>

+ 19 - 0
docs/_i18n/es/documentation/methods.md

@@ -18,6 +18,11 @@ Sintaxis para llamar a un método: `$('#table').bootstrapTable('method', paramet
     </thead>
     <tbody>
     <tr>
+        <td>getOptions</td>
+        <td>none</td>
+        <td>Return the options object.</td>
+    </tr>
+    <tr>
         <td>getSelections</td>
         <td>none</td>
         <td>Retorna todas las filas seleccionadas, cuando no hay seleccionadas, se retorna un array vacío .</td>
@@ -53,6 +58,15 @@ Sintaxis para llamar a un método: `$('#table').bootstrapTable('method', paramet
         </td>
     </tr>
     <tr>
+        <td>insertRow</td>
+        <td>params</td>
+        <td>
+        Insert a new row, the param contains following properties:<br>
+        index: the row index to insert into.<br>
+        row: the row data.
+        </td>
+    </tr>
+    <tr>
         <td>updateRow</td>
         <td>params</td>
         <td>
@@ -138,6 +152,11 @@ Sintaxis para llamar a un método: `$('#table').bootstrapTable('method', paramet
         <td>(Solo se puede usar en client-side)Filtra los datos en la tabla, ejm. se puede filtrar <code>{age: 10}</code> para mostrar los daros solo con la edad igual a 10.</td>
     </tr>
     <tr>
+        <td>selectPage</td>
+        <td>page</td>
+        <td>Go to the a specified page.</td>
+    </tr>
+    <tr>
         <td>prevPage</td>
         <td>none</td>
         <td>Ir a la página anterior.</td>

+ 7 - 0
docs/_i18n/es/documentation/table-options.md

@@ -265,6 +265,13 @@ Las opciones de la tabla están definidas en `jQuery.fn.bootstrapTable.defaults`
         <td>True para mostrar el botón de vista cambiada entre vista de tabla y vista de tarjeta.</td>
     </tr>
     <tr>
+        <td>showPaginationSwitch</td>
+        <td>data-show-pagination-switch</td>
+        <td>Boolean</td>
+        <td>false</td>
+        <td>True to show the pagination switch button.</td>
+    </tr>
+    <tr>
         <td>minimumCountColumns</td>
         <td>data-minimum-count-columns</td>
         <td>Number</td>

+ 26 - 1
docs/_i18n/fr/documentation/methods.md

@@ -18,6 +18,11 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
     </thead>
     <tbody>
     <tr>
+        <td>getOptions</td>
+        <td>none</td>
+        <td>Return the options object.</td>
+    </tr>
+    <tr>
         <td>getSelections</td>
         <td>none</td>
         <td>Return all selected rows, when no record selected, am empty array will return.</td>
@@ -38,12 +43,27 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <td>Append the data to table.</td>
     </tr>
     <tr>
+        <td>prepend</td>
+        <td>data</td>
+        <td>Prepend the data to table.</td>
+    </tr>
+    <tr>
         <td>remove</td>
         <td>params</td>
         <td>
         Remove data from table, the params contains two properties: <br>
         field: the field name of remove rows. <br>
-        values: the values of remove rows.
+        values: the array of values for rows which should be removed. <br>
+        Example: $('#myTable').bootstrapTable('remove', {field: 'id', values: ["73", "74"]})
+        </td>
+    </tr>
+    <tr>
+        <td>insertRow</td>
+        <td>params</td>
+        <td>
+        Insert a new row, the param contains following properties:<br>
+        index: the row index to insert into.<br>
+        row: the row data.
         </td>
     </tr>
     <tr>
@@ -132,6 +152,11 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <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>selectPage</td>
+        <td>page</td>
+        <td>Go to the a specified page.</td>
+    </tr>
+    <tr>
         <td>prevPage</td>
         <td>none</td>
         <td>Go to previous page.</td>

+ 8 - 8
docs/_i18n/fr/documentation/table-options.md

@@ -149,7 +149,7 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         <td>Function</td>
         <td>function(params) {<br>return params;<br>}</td>
         <td>
-        When requesting remote data, you can send additional parameters by modifying queryParams.
+        When requesting remote data, you can send additional parameters by modifying queryParams. 
         If queryParamsType = 'limit', the params object contains: <br>
         limit, offset, search, sort, order
         Else, it contains: <br>
@@ -210,13 +210,6 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         <td>When set pagination property, initialize the page size selecting list.</td>
     </tr>
     <tr>
-        <td>showPaginationSwitch </td>
-        <td>data-show-pagination-switch</td>
-        <td>Boolean</td>
-        <td>false</td>
-        <td>True to show the pagination switch button.</td>
-    </tr>
-    <tr>
         <td>selectItemName</td>
         <td>data-select-item-name</td>
         <td>String</td>
@@ -274,6 +267,13 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         </td>
     </tr>
     <tr>
+        <td>showPaginationSwitch</td>
+        <td>data-show-pagination-switch</td>
+        <td>Boolean</td>
+        <td>false</td>
+        <td>True to show the pagination switch button.</td>
+    </tr>
+    <tr>
         <td>minimumCountColumns</td>
         <td>data-minimum-count-columns</td>
         <td>Number</td>

+ 7 - 1
docs/_i18n/fr/examples/format.md

@@ -2,4 +2,10 @@
 
 Use `formatter` column option to format the display of bootstrap table column. _by [@wenzhixin](https://github.com/wenzhixin)_
 
-<iframe width="100%" height="300" data-src="http://jsfiddle.net/wenyi/e3nk137y/21/embedded/html,js,result" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
+<iframe width="100%" height="300" data-src="http://jsfiddle.net/wenyi/e3nk137y/21/embedded/html,js,result" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
+
+# Show current row count using Formatter []({{ site.repo }}/blob/master/docs/_i18n/{{ site.lang }}/examples/format.md)
+
+Use `formatter` column option to display the index of the current row. _by [@DominikAngerer](https://github.com/DominikAngerer)_
+
+<iframe width="100%" height="300" data-src="http://jsfiddle.net/DominikAngerer/yx275pyd/2/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>

+ 31 - 1
docs/_i18n/zh-cn/documentation/methods.md

@@ -18,6 +18,11 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
     </thead>
     <tbody>
     <tr>
+        <td>getOptions</td>
+        <td>none</td>
+        <td>Return the options object.</td>
+    </tr>
+    <tr>
         <td>getSelections</td>
         <td>none</td>
         <td>Return all selected rows, when no record selected, am empty array will return.</td>
@@ -38,12 +43,27 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <td>Append the data to table.</td>
     </tr>
     <tr>
+        <td>prepend</td>
+        <td>data</td>
+        <td>Prepend the data to table.</td>
+    </tr>
+    <tr>
         <td>remove</td>
         <td>params</td>
         <td>
         Remove data from table, the params contains two properties: <br>
         field: the field name of remove rows. <br>
-        values: the values of remove rows.
+        values: the array of values for rows which should be removed. <br>
+        Example: $('#myTable').bootstrapTable('remove', {field: 'id', values: ["73", "74"]})
+        </td>
+    </tr>
+    <tr>
+        <td>insertRow</td>
+        <td>params</td>
+        <td>
+        Insert a new row, the param contains following properties:<br>
+        index: the row index to insert into.<br>
+        row: the row data.
         </td>
     </tr>
     <tr>
@@ -132,6 +152,11 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <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>selectPage</td>
+        <td>page</td>
+        <td>Go to the a specified page.</td>
+    </tr>
+    <tr>
         <td>prevPage</td>
         <td>none</td>
         <td>Go to previous page.</td>
@@ -141,5 +166,10 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter);`.
         <td>none</td>
         <td>Go to next page.</td>
     </tr>
+    <tr>
+        <td>togglePagination</td>
+        <td>none</td>
+        <td>Toggle the pagination option.</td>
+    </tr>
     </tbody>
 </table>

+ 8 - 1
docs/_i18n/zh-cn/documentation/table-options.md

@@ -149,7 +149,7 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         <td>Function</td>
         <td>function(params) {<br>return params;<br>}</td>
         <td>
-        When requesting remote data, you can send additional parameters by modifying queryParams.
+        When requesting remote data, you can send additional parameters by modifying queryParams. 
         If queryParamsType = 'limit', the params object contains: <br>
         limit, offset, search, sort, order
         Else, it contains: <br>
@@ -267,6 +267,13 @@ The table options is defined in `jQuery.fn.bootstrapTable.defaults`.
         </td>
     </tr>
     <tr>
+        <td>showPaginationSwitch</td>
+        <td>data-show-pagination-switch</td>
+        <td>Boolean</td>
+        <td>false</td>
+        <td>True to show the pagination switch button.</td>
+    </tr>
+    <tr>
         <td>minimumCountColumns</td>
         <td>data-minimum-count-columns</td>
         <td>Number</td>

+ 7 - 1
docs/_i18n/zh-cn/examples/format.md

@@ -2,4 +2,10 @@
 
 Use `formatter` column option to format the display of bootstrap table column. _by [@wenzhixin](https://github.com/wenzhixin)_
 
-<iframe width="100%" height="300" data-src="http://jsfiddle.net/wenyi/e3nk137y/21/embedded/html,js,result" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
+<iframe width="100%" height="300" data-src="http://jsfiddle.net/wenyi/e3nk137y/21/embedded/html,js,result" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
+
+# Show current row count using Formatter []({{ site.repo }}/blob/master/docs/_i18n/{{ site.lang }}/examples/format.md)
+
+Use `formatter` column option to display the index of the current row. _by [@DominikAngerer](https://github.com/DominikAngerer)_
+
+<iframe width="100%" height="300" data-src="http://jsfiddle.net/DominikAngerer/yx275pyd/2/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>

+ 23 - 5
src/bootstrap-table.js

@@ -781,6 +781,7 @@
         this.totalPages = 0;
         if (this.options.totalRows) {
             this.totalPages = ~~((this.options.totalRows - 1) / this.options.pageSize) + 1;
+            this.options.totalPages = this.totalPages;
         }
         if (this.totalPages > 0 && this.options.pageNumber > this.totalPages) {
             this.options.pageNumber = this.totalPages;
@@ -1493,6 +1494,10 @@
         $td.attr('rowspan', rowspan).attr('colspan', colspan).show();
     };
 
+    BootstrapTable.prototype.getOptions = function () {
+        return this.options;
+    };
+
     BootstrapTable.prototype.getSelections = function () {
         var that = this;
 
@@ -1536,6 +1541,7 @@
         this.$container.next().remove();
         this.$container.remove();
         this.$el.html(this.$el_.html())
+            .css('margin-top', '0')
             .attr('class', this.$el_.attr('class') || ''); // reset the class
     };
 
@@ -1591,20 +1597,32 @@
         }
     };
 
+    BootstrapTable.prototype.selectPage = function (page) {
+        if (page > 0 && page <= this.options.totalPages) {
+            this.options.pageNumber = page;
+            this.updatePagination();
+        }
+    };
+
     BootstrapTable.prototype.prevPage = function () {
-        this.options.pageNumber > 1 ? this.options.pageNumber-- : null;
-        this.updatePagination();
+        if (this.options.pageNumber > 1) {
+            this.options.pageNumber--;
+            this.updatePagination();
+        }
     };
 
     BootstrapTable.prototype.nextPage = function () {
-        this.options.pageNumber < this.options.pageSize ? this.options.pageNumber++ : null;
-        this.updatePagination();
+        if (this.options.pageNumber < this.options.totalPages) {
+            this.options.pageNumber++;
+            this.updatePagination();
+        }
     };
 
     // BOOTSTRAP TABLE PLUGIN DEFINITION
     // =======================
 
     var allowedMethods = [
+        'getOptions',
         'getSelections', 'getData',
         'load', 'append', 'prepend', 'remove',
         'insertRow', 'updateRow',
@@ -1618,7 +1636,7 @@
         'showColumn', 'hideColumn',
         'filterBy',
         'scrollTo',
-        'prevPage', 'nextPage',
+        'selectPage', 'prevPage', 'nextPage',
         'togglePagination'
     ];