Browse Source

Update remove key to field and add docs.

zhixin 11 years ago
parent
commit
46a38b74c8
3 changed files with 9 additions and 8 deletions
  1. 5 4
      docs/docs.js
  2. 1 1
      docs/examples.html
  3. 3 3
      src/bootstrap-table.js

+ 5 - 4
docs/docs.js

@@ -652,10 +652,11 @@ $(function () {
             ]
         }).bootstrapTable('load', [
                 {name: 'getSelections', parameter: 'none', description: 'Return all selected rows, when no record selected, am empty array will return.'},
-                {name: 'getData', parameter: 'none', description: 'Get the data of table.'},
-                {name: 'load', parameter: 'data', description: 'Load the data to table.'}
+                {name: 'getData', parameter: 'none', description: 'Get the loaded data of table.'},
+                {name: 'load', parameter: 'data', description: 'Load the data to table, the old rows will be removed.'}
             ]).bootstrapTable('append', [
                 {name: 'append', parameter: 'data', description: 'Append the data to table.'},
+                {name: 'remove', parameter: 'params', description: 'Remove data from table, the params contains two properties: <br>field: the field name of remove rows. <br>values: the values of remove rows.'},
                 {name: 'mergeCells', parameter: 'options', description: 'Merge some cells to one cell, the options contains following properties:'},
                 {name: 'mergeCells', parameter: 'options', description: 'index: the row index.'},
                 {name: 'mergeCells', parameter: 'options', description: 'field: the field name.'},
@@ -671,11 +672,11 @@ $(function () {
                 {name: 'showColumn', parameter: 'field', description: 'Show the specified column.'},
                 {name: 'hideColumn', parameter: 'field', description: 'Hide the specified column.'}
             ]).bootstrapTable('mergeCells', {
-                index: 4,
+                index: 5,
                 field: 'name',
                 rowspan: 5
             }).bootstrapTable('mergeCells', {
-                index: 4,
+                index: 5,
                 field: 'parameter',
                 rowspan: 5
             });

+ 1 - 1
docs/examples.html

@@ -957,7 +957,7 @@
                                         });
 
                                     $table.bootstrapTable('remove', {
-                                        key: 'id',
+                                        field: 'id',
                                         values: ids
                                     });
                                 });

+ 3 - 3
src/bootstrap-table.js

@@ -1140,17 +1140,17 @@
         var len = this.options.data.length,
             i, row;
 
-        if (!params.hasOwnProperty('key') || !params.hasOwnProperty('values')) {
+        if (!params.hasOwnProperty('field') || !params.hasOwnProperty('values')) {
             return;
         }
 
         for (i = len - 1; i >= 0; i--) {
             row = this.options.data[i];
 
-            if (!row.hasOwnProperty(params.key)) {
+            if (!row.hasOwnProperty(params.field)) {
                 return;
             }
-            if (params.values.indexOf(row[params.key]) !== -1) {
+            if (params.values.indexOf(row[params.field]) !== -1) {
                 this.options.data.splice(i, 1);
             }
         }