Browse Source

making formatter api like cellStyle

Gabriel Pedro 8 years ago
parent
commit
002c474905
2 changed files with 13 additions and 2 deletions
  1. 12 1
      docs/_i18n/en/documentation/column-options.md
  2. 1 1
      src/bootstrap-table.js

+ 12 - 1
docs/_i18n/en/documentation/column-options.md

@@ -164,7 +164,18 @@ The column options is defined in `jQuery.fn.bootstrapTable.columnDefaults`.
         The cell formatter function, take three parameters: <br>
         value: the field value. <br>
         row: the row record data.<br>
-        index: the row index.</td>
+        index: the row index.<br>
+        field: the row field.<br>
+        Example usage:<br>
+<pre>
+function formatter(value, row, index, field) {
+  if (value === 'foo') {
+    return '<strong>' + value + '</strong>';
+  }
+  return value;
+}
+</pre>
+        </td>
     </tr>
     <tr>
         <td>footerFormatter</td>

+ 1 - 1
src/bootstrap-table.js

@@ -1736,7 +1736,7 @@
             }
 
             value = calculateObjectValue(column,
-                that.header.formatters[j], [value_, item, i], value_);
+                that.header.formatters[j], [value_, item, i, field], value_);
 
             if (item['_' + field + '_data'] && !$.isEmptyObject(item['_' + field + '_data'])) {
                 $.each(item['_' + field + '_data'], function(k, v) {