(本文档仅供参考,仅适用于本文档中的示例报表/场景,若实际报表/场景与示例代码无法完全适配(如使用功能不一致,或多个宏代码冲突等),需根据实际需求开发代码。)
问题
参考wiki实现选中行高亮,怎么同时修改字体颜色。
解决方案
/*类型 ClientSide 对象 SpreadsheetReport 事件 onRender*/ function main(spreadsheetReport) { spreadsheetReport._focusTR = null; spreadsheetReport.initTableGrid(); spreadsheetReport.addListener(spreadsheetReport.elemSheetFrame.contentWindow.document.body, "click", function(e) { var t = e.target; while (t && t.tagName != "TR") t = t.parentNode; if (!t) return; if (this._focusTR) { var tdRow = this.tableGrid[this._focusTR.rowIndex]; for (var i = 0; i < tdRow.length; i++) { tdRow[i].style.backgroundColor = tdRow[i]._originalBackgroundColor; tdRow[i].style.color = tdRow[i]._originalColor; } } this._focusTR = t; var tdRow = this.tableGrid[t.rowIndex]; for (var i = 0; i < tdRow.length; i++) { var td = tdRow[i]; if (typeof td._originalBackgroundColor == "undefined") { td._originalBackgroundColor = td.style.backgroundColor; td._originalColor = td.style.color; } td.style.backgroundColor = "#ffc9af"; td.style.color = "red"; } }, spreadsheetReport, "sheetFrameBody"); }