页面树结构

版本比较

标识

  • 该行被添加。
  • 该行被删除。
  • 格式已经改变。

...

代码块
languagejs
linenumberstrue
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导出Excel,注:如是清单表则导出当前页数据
};


关键对象总结

  • 通过spreadsheetReport.elem_btnPrint.parentNode.appendChild 方法,将新创建的按钮添加到工具栏的尾部。
  • 利用spreadsheetReport.addListener 方法,为新创建的按钮绑定事件处理函数。

...