注意 | ||
---|---|---|
| ||
本文档的示例代码仅适用于本文档中的示例报表/场景。若实际报表/场景与示例代码无法完全适配(如使用功能不一致,或多个宏代码冲突等),需根据实际需求开发代码。 |
示例说明
在项目中有时间需要在参数的后面添加一个按钮。可以通过宏实现该需求。效果图如下:
...
类型 | 对象 | 事件 |
---|---|---|
ClientSide | spreadsheetReport | onRenderReport |
...
宏代码
代码块 | ||||
---|---|---|---|---|
| ||||
function main(spreadsheetReport) { // debugger; // 获取电子表格参数面板 var lastCell = spreadsheetReport.paramPanelObj; var paramTable = spreadsheetReport.paramPanelObj.layoutTable; var i, cell, lastCell; // ============在参数同一行添加按钮 for (i = 0; i < paramTable.rows.length; i++) { cell = paramTable.rows[i].insertCell(-1); if (i == paramTable.rows.length - 1) lastCell = cell; } // 在参数后面一行添加按钮,可以使用如下代码 /* * var row = paramTable.insertRow(); * row.style.height = "20px"; * lastCell = row.insertCell( - 1); * lastCell.colSpan = paramTable.rows[0].cells.length; * lastCell.align = "center"; */ if (!spreadsheetReport._newBtn) {// 不重复添加按钮 var input = document.createElement("INPUT"); input.type = "button"; // input.className = "button-buttonbar button-bgicon-save"; input.value = "刷新按钮"; input.title = "刷新按钮"; // input.accessKey = "N"; input.style.width = "100"; input.style.height = "20"; var newBtn = lastCell.appendChild(input); spreadsheetReport.addListener(input, "click", doNewButtonClick, spreadsheetReport); spreadsheetReport._newBtn = newBtn; } // debugger; // 新添加按钮Click事件处理函数 function doNewButtonClick(e) { spreadsheetReport.doRefresh(); // alert("TODO:Click事件处理函数。"); spreadsheetReport.doRefresh(true);// 刷新报表 } } |
...