我利用添加CSS类的方式定义颜色和javascript中添加类的方式,就避免了有滚动条引发的错误的颜色渲染.- gridPivot.onFormatItem = function(e) {
- if (e.panel == this.cells && e.panel.columns[e.col].binding.includes('Diff')) {
- var value = this.getCellData(e.row, e.col);
- var glyph, color = "#d8b400";
- if(value != null) {
- if(value < 0) { // negative variation
- glyph = 'down';
- // color = "#9f0000";
- e.cell.className += ' declining';
- } else if(value > 0.05) { // positive variation
- glyph = 'up';
- // color = "#4c8f00";
- e.cell.className += ' rise';
- } else {
- // glyph = 'circle'
- e.cell.className += ' static';
- }
- }
- // e.cell.style.color = color;
- e.cell.innerHTML += ' <span style="font-size:120%;" class="wj-glyph-' + glyph + '"></span>';
- }
- };
复制代码 |