Browse Source

Fix #8: add index argument in formatter function.

zhixin 11 years ago
parent
commit
1834d4d14d
2 changed files with 3 additions and 3 deletions
  1. 1 1
      docs/docs.js
  2. 2 2
      src/bootstrap-table.js

+ 1 - 1
docs/docs.js

@@ -222,7 +222,7 @@ $(function () {
             {
             {
                 name: 'formatter',
                 name: 'formatter',
                 type: 'Function',
                 type: 'Function',
-                description: 'The cell formatter function, take two parameters: <br />value: the field value. <br />row: the row record data.',
+                description: 'The cell formatter function, take two parameters: <br />value: the field value. <br />row: the row record data.<br />index: the row index.',
                 'default': 'undefined'
                 'default': 'undefined'
             },
             },
             {
             {

+ 2 - 2
src/bootstrap-table.js

@@ -554,9 +554,9 @@
                     style = sprintf('style="%s"', that.header.styles[j]);
                     style = sprintf('style="%s"', that.header.styles[j]);
 
 
                 if (typeof that.header.formatters[j] === 'function') {
                 if (typeof that.header.formatters[j] === 'function') {
-                    value = that.header.formatters[j](value, item);
+                    value = that.header.formatters[j](value, item, i);
                 } else if (typeof that.header.formatters[j] === 'string') {
                 } else if (typeof that.header.formatters[j] === 'string') {
-                    value = eval(that.header.formatters[j] + '(value, item)'); // eval ?
+                    value = eval(that.header.formatters[j] + '(value, item, i)'); // eval ?
                 }
                 }
 
 
                 if (that.options.columns[j].checkbox || that.options.columns[j].radio) {
                 if (that.options.columns[j].checkbox || that.options.columns[j].radio) {