Browse Source

Update boostrap-table.js

adding updateCellById method. to be called with {id, field, value}
pokica-hu 9 years ago
parent
commit
c347961b56
1 changed files with 28 additions and 1 deletions
  1. 28 1
      src/bootstrap-table.js

+ 28 - 1
src/bootstrap-table.js

@@ -2627,6 +2627,33 @@
         this.initBody(true);
     };
 
+    BootstrapTable.prototype.updateCellById = function (params) {
+        var that = this;
+        if (!params.hasOwnProperty('id') ||
+            !params.hasOwnProperty('field') ||
+            !params.hasOwnProperty('value')) {
+            return;
+        }
+        var allParams = $.isArray(params) ? params : [ params ];
+
+        $.each(allParams, function(i, params) {
+            var rowId;
+
+            rowId = $.inArray(that.getRowByUniqueId(params.id), that.options.data);
+
+            if (rowId === -1) {
+                return;
+            }
+            that.data[rowId][params.field] = params.value
+        });
+
+        if (params.reinit === false) {
+            return;
+        }
+        this.initSort();
+        this.initBody(true);
+    };
+    
     BootstrapTable.prototype.getOptions = function () {
         return this.options;
     };
@@ -3001,7 +3028,7 @@
         'refreshOptions',
         'resetSearch',
         'expandRow', 'collapseRow', 'expandAllRows', 'collapseAllRows',
-        'updateFormatText'
+        'updateFormatText', 'updateCellById'
     ];
 
     $.fn.bootstrapTable = function (option) {