翻譯|使用教程|編輯:王香|2018-09-28 11:39:48.000|閱讀 1040 次
概述:本文主要介紹了Stimulsoft報表中如何在Web查看器的工具欄上添加自定義按鈕。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
【下載Stimulsoft Reports.Net最新版本】
此示例項目演示了如何在Web查看器的工具欄上添加自定義按鈕。您可以設置自定義按鈕的標題和圖標,并添加單擊事件。 例如,在工具欄上添加自定義按鈕并定義單擊事件,在其中顯示警報消息。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="Custom_Button_on_the_Toolbar_of_the_Viewer.Default" %>
<%@ Register assembly="Stimulsoft.Report.Web" namespace="Stimulsoft.Report.Web" tagprefix="cc1" %>
<!DOCTYPE html>
<html xmlns="//www.w3.org/1999/xhtml">
<head runat="server">
<title>Custom Button on the Toolbar of the Viewer</title>
</head>
<body>
<form id="form1" runat="server">
<cc1:StiWebViewer ID="StiWebViewer1" runat="server"
OnGetReport="StiWebViewer1_GetReport" />
</form>
<script type="text/javascript">
...
</script>
</body>
</html>
要添加按鈕,您可以使用簡單的JavaScript代碼。首先,使用位于Web查看器對象中的SmallButton()構造函數(shù)創(chuàng)建自定義按鈕對象。接下來,獲取工具欄按鈕容器并插入按鈕對象。
var customButton = jsStiWebViewer1.SmallButton("customButton", "Custom Button", "emptyImage");
customButton.image.src = "//www.stimulsoft.com/favicon.png";
customButton.action = function () {
alert("Custom Button Event");
}
var toolbarTable = jsStiWebViewer1.controls.toolbar.firstChild.firstChild;
var buttonsTable = toolbarTable.rows[0].firstChild.firstChild;
var customButtonCell = buttonsTable.rows[0].insertCell(0);
customButtonCell.appendChild(customButton);
示例代碼的結果如下圖所示:

購買Stimulsoft正版授權,請點擊“”喲!
本站文章除注明轉載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn