...
代码块 | ||||
---|---|---|---|---|
| ||||
function main(spreadsheetReport) {
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 = "55";
input.style.height = "20";
var newBtn = spreadsheetReport.elem_btnPrint.parentNode.appendChild(input);
spreadsheetReport.addListener(newBtn, "click", doNewButtonClick, spreadsheetReport);
spreadsheetReport._newBtn = newBtn;
}
};
// 新添加按钮Click事件处理函数
function doNewButtonClick(e) {
alert("TODO:Click事件处理函数。");
//此处可以参考下列示例调用电子表格的相关方法
//this.doPrint(true, false);//打印
//清单报表导出有如下方法
//this.doExportMenuCloseUp("CSV");//导出CSV,清单报表,分组不支持
//this.doExportMenuCloseUp("LIST_EXCEL");//导出Excel
//分组报表导出有如下方法
//this.doExportMenuCloseUp("HTML");//导出HTML
//this.doExportMenuCloseUp("PDF");//导出PDF
//this.doExportMenuCloseUp("WORD");//导出Word
//this.doExportMenuCloseUp("EXCEL2007");//导出Excel
};
|
关键对象总结
通过spreadsheetReport.elem_btnPrint.parentNode.appendChild 方法,将新创建的按钮添加到工具栏的尾部。
- 利用spreadsheetReport.addListener 方法,为新创建的按钮绑定事件处理函数。
...