客户想在前端电子表格报表上添加按钮,点击执行特定的计划任务。
V11
通过宏代码调用有以下几点需要注意:
类型 | 对象 | 事件 |
---|---|---|
ClientSide | spreadsheetReport | onRenderReport |
function main(spreadsheetReport, isAjaxRefreshCallback) { if (!spreadsheetReport._newBtn) { // 不要重复添加按钮 var input = document.createElement("button"); //input.className = "button-buttonbar button-bgicon-save"; input.innerText = "执行任务"; input.title = "新添加的按钮"; input.accessKey = "N"; input.style.width = "50px"; input.style.height = "25px"; input.style.verticalAlign = 'top'; input.style.marginLeft = "12px"; var target = spreadsheetReport.elem_btnPrint.parentNode.nextSibling; var newBtn = target.parentNode.insertBefore(input, target); spreadsheetReport.addListener(newBtn, "click", doRunTask, spreadsheetReport); spreadsheetReport._newBtn = newBtn; } } // 新添加按钮Click事件处理函数 function doRunTask() { var taskId = "I8a74a40701919e5b9e5b45220191a21013875f56";//任务ID var crateUser = "admin";//任务创建用户 var util = jsloader.resolve("freequery.common.util"); var ret = util.remoteInvoke('ScheduleSDK', 'runTaskByid', [taskId, crateUser]); //检查ret返回结果..... } |