Browse Source

fix(js): fix #2385, checkbox render bug with formatter

zhixin 9 years ago
parent
commit
770b1f8c0c
2 changed files with 7 additions and 5 deletions
  1. 1 0
      CHANGELOG.md
  2. 6 5
      src/bootstrap-table.js

+ 1 - 0
CHANGELOG.md

@@ -5,6 +5,7 @@ ChangeLog
 
 - fix(js): fix #2439, `filterBy` cannot filter array keys
 - fix(js): fix #2424, from html with checkbox bug
+- fix(js): fix #2385, checkbox render bug with formatter
 - feat(js): fix #2414, add `paginationLoop` option
 - feat(cookie extension): fix #2386, add `getCookies` method
 

+ 6 - 5
src/bootstrap-table.js

@@ -1668,7 +1668,8 @@
 
             $.each(this.header.fields, function (j, field) {
                 var text = '',
-                    value = getItemField(item, field, that.options.escape),
+                    value_ = getItemField(item, field, that.options.escape),
+                    value = '',
                     type = '',
                     cellStyle = {},
                     id_ = '',
@@ -1679,7 +1680,7 @@
                     title_ = '',
                     column = that.columns[j];
 
-                if (that.fromHtml && typeof value === 'undefined') {
+                if (that.fromHtml && typeof value_ === 'undefined') {
                     return;
                 }
 
@@ -1710,7 +1711,7 @@
                     title_ = sprintf(' title="%s"', item['_' + field + '_title']);
                 }
                 cellStyle = calculateObjectValue(that.header,
-                    that.header.cellStyles[j], [value, item, i, field], cellStyle);
+                    that.header.cellStyles[j], [value_, item, i, field], cellStyle);
                 if (cellStyle.classes) {
                     class_ = sprintf(' class="%s"', cellStyle.classes);
                 }
@@ -1723,7 +1724,7 @@
                 }
 
                 value = calculateObjectValue(column,
-                    that.header.formatters[j], [value, item, i], value);
+                    that.header.formatters[j], [value_, item, i], value_);
 
                 if (item['_' + field + '_data'] && !$.isEmptyObject(item['_' + field + '_data'])) {
                     $.each(item['_' + field + '_data'], function (k, v) {
@@ -1747,7 +1748,7 @@
                         sprintf(' type="%s"', type) +
                         sprintf(' value="%s"', item[that.options.idField]) +
                         sprintf(' checked="%s"', value === true ||
-                        (value && value.checked) ? 'checked' : undefined) +
+                        (value_ || value && value.checked) ? 'checked' : undefined) +
                         sprintf(' disabled="%s"', !column.checkboxEnabled ||
                         (value && value.disabled) ? 'disabled' : undefined) +
                         ' />',