當前為10.0版本文檔,更多實例內容將在最新幫助文檔中展現,點選跳轉至 最新版幫助文檔

自定義提交按鈕

1. 概述

1.1 問題描述

在我們使用填報表時,有時只需要提交按鈕将數據入庫,不希望使用 FR 内置的工具欄的按鈕,希望能夠自定義提交按鈕。
自定義按鈕既可以是 FineReport 模板中添加的按鈕控件,也可以是 Web 集成頁面中,HTML 的按鈕标簽。
(1)FineReport 模板中的按鈕控件實現自定義提交操作詳細請參照 自定義按鈕中實現提交操作
(2)而在 Web 頁面中,點擊 HTML 中的按鈕提交 iframe 中的 FineReport 報表就在下面詳述。

效果如下圖:

222

1.2 實現思路

FR 中内置的報表提交 JS 代碼是contentPane.writeReport(),如果是調用嵌入的報表提交功能的話,使用document.getElementById('報表所在iframe的id').contentWindow.contentPane.writeReport();

2. 操作步驟

2.1 編輯模板

使用模板%FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc\Form\FreeFrom\FreeForm.cpt

2.2 編輯 HTML 代碼

在網頁中添加按鈕代碼如下:

<button type="button" onclick="document.getElementById('reportFrame').contentWindow.contentPane.writeReport()">提交</button>

完整代碼:


<html>     
<head>     
<title>自定義提交按鈕</title>   
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
</head>     
<body>     
<div id="toolbar">     
<button type="button" onclick="document.getElementById('reportFrame').contentWindow.contentPane.writeReport()">提交</button>
</div>     
<iframe id="reportFrame" onload="afterload()" src="/webroot/decision/view/report?viewlet=doc/Form/FreeFrom/FreeForm.cpt&op=write&__showtoolbar__=false" width = 100% height = 80%></iframe>     
</body>     
</html> 

已完成示例請參照%FR_HOME%\webapps\webroot\help\page_demo\write.html


2.3 效果預覽

啓動設計器,在浏覽器輸入:http://localhost:8075/webroot/help/page_demo/write.html,效果如下圖:

3. 已完成模板

已完成頁面請查看%FR_HOME%/webapps/webroot/help/page_demo/write.html

點擊下載頁面

write.html


附件列表


主題: 原簡體文檔
  • 有幫助
  • 沒幫助
  • 只是瀏覽

文 檔回 饋

滑鼠選中內容,快速回饋問題

滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

不再提示

9s后關閉

反饋已提交

網絡繁忙