|
655 | 655 | } |
656 | 656 | return classList.join(' '); |
657 | 657 | }, |
658 | | - readContent: function(row, column) { |
| 658 | + readContent: function(row, column) { |
659 | 659 | var datum = row[column.name]; |
660 | | - if (datum === null || datum === undefined |
| 660 | + if (column.renderer !== null && column.renderer !== undefined |
| 661 | + && typeof column.renderer === 'string' && column.renderer.trim().length > 0) { |
| 662 | + datum = this._render(column.renderer, datum, row, column); |
| 663 | + } |
| 664 | + if (datum === null || datum === undefined |
661 | 665 | || typeof datum === 'string' && datum.trim().length === 0) { |
662 | 666 | var options = column.options; |
663 | 667 | var blank = column.placeholder; |
|
1103 | 1107 | e.target.classList.toggle('search'); |
1104 | 1108 | e.target.classList.toggle('nosearch'); |
1105 | 1109 | this.$$('#filter').classList.toggle('hide'); |
1106 | | - } |
| 1110 | + }, |
| 1111 | + _render: function(name, datum, row, col) { |
| 1112 | + var args = [ datum, row, col, this ]; |
| 1113 | + var displayValue = this._invokeRenderer(datum, name, args); |
| 1114 | + if (displayValue !== null) { |
| 1115 | + return displayValue; |
| 1116 | + } |
| 1117 | + displayValue = this._invokeRenderer(row, name, args); |
| 1118 | + if (displayValue !== null) { |
| 1119 | + return displayValue; |
| 1120 | + } |
| 1121 | + |
| 1122 | + displayValue = this._invokeRenderer(this, name, args); |
| 1123 | + if (displayValue !== null) { |
| 1124 | + return displayValue; |
| 1125 | + } |
| 1126 | + |
| 1127 | + displayValue = this._invokeRenderer(this.domHost, name, args); |
| 1128 | + if (displayValue === null || displayValue === undefined) { |
| 1129 | + displayValue = datum; |
| 1130 | + } |
| 1131 | + return displayValue; |
| 1132 | + }, |
| 1133 | + _invokeRenderer: function (b, name, args) { |
| 1134 | + var fn = b[name]; |
| 1135 | + if (fn) { |
| 1136 | + return fn.apply(this, args || Polymer.nar); |
| 1137 | + } |
| 1138 | + return null; |
| 1139 | + } |
| 1140 | + |
1107 | 1141 | }); |
1108 | 1142 | </script> |
1109 | 1143 |
|
|
1188 | 1222 | searchplaceholder: { |
1189 | 1223 | type: String, |
1190 | 1224 | value: "" |
1191 | | - } |
| 1225 | + }, |
| 1226 | + //renderer - function called to display value |
| 1227 | + renderer: { |
| 1228 | + type: String |
| 1229 | + } |
1192 | 1230 | } |
1193 | 1231 | }); |
1194 | 1232 | </script> |
|
0 commit comments