浏览代码

Fix #1452: integer field and checkbox bugs.

zhixin 10 年之前
父节点
当前提交
618128ace1
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      src/bootstrap-table.js

+ 6 - 4
src/bootstrap-table.js

@@ -213,11 +213,13 @@
 
 
     var getItemField = function (item, field) {
     var getItemField = function (item, field) {
         var value = item;
         var value = item;
-        if (field !== undefined) {
+        if (typeof field === 'string') {
             var props = field.split('.');
             var props = field.split('.');
             for (var p in props) {
             for (var p in props) {
                 value = value[props[p]];
                 value = value[props[p]];
             }
             }
+        } else {
+            return item[field];
         }
         }
         return value;
         return value;
     }
     }
@@ -1500,7 +1502,7 @@
                         sprintf(' disabled="%s"', !column.checkboxEnabled ||
                         sprintf(' disabled="%s"', !column.checkboxEnabled ||
                         (value && value.disabled) ? 'disabled' : undefined) +
                         (value && value.disabled) ? 'disabled' : undefined) +
                         ' />',
                         ' />',
-                        column.formatter ? value : '',
+                        that.header.formatters[j] ? value : '',
                         that.options.cardView ? '</div>' : '</td>'
                         that.options.cardView ? '</div>' : '</td>'
                     ].join('');
                     ].join('');
 
 
@@ -1556,7 +1558,7 @@
                 item = that.data[$tr.data('index')],
                 item = that.data[$tr.data('index')],
                 index = $td[0].cellIndex,
                 index = $td[0].cellIndex,
                 field = that.header.fields[that.options.detailView && !that.options.cardView ? index - 1 : index],
                 field = that.header.fields[that.options.detailView && !that.options.cardView ? index - 1 : index],
-                colomn = that.columns[getFieldIndex(that.columns, field)],
+                column = that.columns[getFieldIndex(that.columns, field)],
                 value = getItemField(item, field);
                 value = getItemField(item, field);
 
 
             if ($td.find('.detail-icon').length) {
             if ($td.find('.detail-icon').length) {
@@ -1567,7 +1569,7 @@
             that.trigger(e.type === 'click' ? 'click-row' : 'dbl-click-row', item, $tr);
             that.trigger(e.type === 'click' ? 'click-row' : 'dbl-click-row', item, $tr);
 
 
             // if click to select - then trigger the checkbox/radio click
             // if click to select - then trigger the checkbox/radio click
-            if (e.type === 'click' && that.options.clickToSelect && colomn.clickToSelect) {
+            if (e.type === 'click' && that.options.clickToSelect && column.clickToSelect) {
                 var $selectItem = $tr.find(sprintf('[name="%s"]', that.options.selectItemName));
                 var $selectItem = $tr.find(sprintf('[name="%s"]', that.options.selectItemName));
                 if ($selectItem.length) {
                 if ($selectItem.length) {
                     $selectItem[0].click(); // #144: .trigger('click') bug
                     $selectItem[0].click(); // #144: .trigger('click') bug