您好,请参考以下链接的示例解决这个问题
https://jscodemine.grapecity.com/sample/IPu05aWqXEm2UA-279Ve_w/
关键代码
- // custom rendering for "Diff" columns
- if (e.panel == s.cells) {
- var col = s.columns[e.col];
- if (e.row > 0 && (col.binding == 'salesDiff' || col.binding == 'expensesDiff')) {
- var vnow = s.getCellData(e.row, e.col - 1), vprev = s.getCellData(e.row - 1, e.col - 1), diff = (vnow / vprev) - 1;
- console.log(e.col,s.columns[e.col]);
- // Only apply background color to "Diff" columns
- if (col.binding == 'salesDiff' || col.binding == 'expensesDiff') {
- e.cell.style.backgroundColor = "#FF7452";
- }
-
- // format the cell
- var html = '<div class="diff-{cls}">' +
- '<span style="font-size:75%">{val}</span> ' +
- '<span style="font-size:120%" class="wj-glyph-{glyph}"></span>';
- html = html.replace('{val}', Globalize.format(diff, col.format));
- if (diff < 0.01) {
- html = html.replace('{cls}', 'down').replace('{glyph}', 'down');
- }
- else if (diff > 0.01) {
- html = html.replace('{cls}', 'up').replace('{glyph}', 'up');
- }
- else {
- html = html.replace('{cls}', 'none').replace('{glyph}', 'circle');
- }
- e.cell.innerHTML = html;
- } else {
- // Clear background color for non-"Diff" columns
- e.cell.style.backgroundColor = '';
- }
- }
- });
复制代码 |