浏览代码

changed context of column.formatter() to column

Prior to this change, there is no way to identify column.field
from the formatter. The context (this) of column.formatter()
was table.header. which served no practical purpose.
jtrumbull 10 年之前
父节点
当前提交
3ce92c69cf
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      src/bootstrap-table.js

+ 6 - 4
src/bootstrap-table.js

@@ -952,11 +952,13 @@
             this.data = s ? $.grep(this.data, function (item, i) {
                 for (var key in item) {
                     key = $.isNumeric(key) ? parseInt(key, 10) : key;
-                    var value = item[key];
+                    var value = item[key],
+                        column = that.options.columns[getFieldIndex(that.options.columns, key)],
+                        j = $.inArray(key, that.header.fields);
 
                     // Fix #142: search use formated data
-                    value = calculateObjectValue(that.header,
-                        that.header.formatters[$.inArray(key, that.header.fields)],
+                    value = calculateObjectValue(column,
+                        that.header.formatters[j],
                         [value, item, i], value);
 
                     var index = $.inArray(key, that.header.fields);
@@ -1290,7 +1292,7 @@
 
                 style = sprintf('style="%s"', csses.concat(that.header.styles[j]).join('; '));
 
-                value = calculateObjectValue(that.header,
+                value = calculateObjectValue(column,
                     that.header.formatters[j], [value, item, i], value);
 
                 // handle td's id and class