浏览代码

Merge pull request #2882 from pokica-hu/patch-1

Update boostrap-table.js
文翼 8 年之前
父节点
当前提交
ec54829430
共有 1 个文件被更改,包括 28 次插入1 次删除
  1. 28 1
      src/bootstrap-table.js

+ 28 - 1
src/bootstrap-table.js

@@ -2698,6 +2698,33 @@
         this.initBody(true);
         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 () {
     BootstrapTable.prototype.getOptions = function () {
         //Deep copy
         //Deep copy
         return $.extend(true, {}, this.options);
         return $.extend(true, {}, this.options);
@@ -3080,7 +3107,7 @@
         'refreshOptions',
         'refreshOptions',
         'resetSearch',
         'resetSearch',
         'expandRow', 'collapseRow', 'expandAllRows', 'collapseAllRows',
         'expandRow', 'collapseRow', 'expandAllRows', 'collapseAllRows',
-        'updateFormatText'
+        'updateFormatText', 'updateCellById'
     ];
     ];
 
 
     $.fn.bootstrapTable = function (option) {
     $.fn.bootstrapTable = function (option) {