赞
踩
Stimulsoft Ultimate (原Stimulsoft Reports.Ultimate)是用于创建报表和仪表板的通用工具集。该产品包括用于WinForms、ASP.NET、.NET Core、JavaScript、WPF、PHP、Java和其他环境的完整工具集。无需比较产品功能,Stimulsoft Ultimate包含了所有内容!
在本文中,我们为JS报告工具中的查看器事件提供了全面的指南,包括它们的详细描述、参数列表等一系列详细内容。在上一篇文章中,我们讨论了报告事件,而在这篇文章中,我们将讨论查看器事件。
Stimulsoft Reports官方正版下载(qun:740060302)https://www.evget.com/product/2398/download
准备变量
该事件在报表构建开始时、在报表中填充变量之前触发。它在StiReport实例上处理onPrepareVariables事件后立即发生。以下是事件处理程序参数的列表:
{
event: "PrepareVariables",
sender: "Viewer",
report: StiReport,preventDefault: boolean,
async: boolean,
variables: []
}
替换变量值的示例:
viewer.onPrepareVariables = (args, callback) => {
args.variables[0].value = "Replace value";
}
开始处理数据
该事件在请求构建报告所需的数据之前触发。它在StiReport实例上处理onBeginProcessData事件后立即发生。以下是事件处理程序参数的列表:
{
sender: "Viewer",
event: "BeginProcessData",
report: StiReport,preventDefault: boolean,
async: boolean,
command: string,
database: string,
connection: string,headers: [],
withCredentials: string,
// Json
pathData: string,
tryParseDateTime: boolean,
relationDirection: StiRelationDirection,// Xsd
pathSchema: string,// Xml
pathData: string,
tryParseDateTime: boolean,
relationDirection: StiRelationDirection,
// Excel
pathData: string,
firstRowIsHeader: boolean,// OData
connectionString: string,
dataSource: string,
collectionName: string,// Sql
connectionString: string,
dataSource: string,
queryString: string,
timeout: number,
parameters: { name: string, value: string | number }[],
escapeQueryParameters: boolean,// Gis
pathData: string,
separator: string,
dataType: StiGisDataType,// Csv
pathData: string,
separator: string,
codePage: number,// DBase
pathData: string,
codePage: number
}
下面是替换连接字符串的示例:
viewer.onBeginProcessData = (args) => {
if (args.database == "MySQL")
args.connectionString = "new connection string";
}
这是我们自己实现数据检索的示例:
viewer.onBeginProcessData = (args, callback) => {
if (args.database == "MySQL"){
args.preventDefault = true;var result = {
success: true,rows: [
["value1", 1, false],
["value2", 1, true],
["value3", 2, false]
],
columns: [
"Column1_name",
"Column2_name",
"Column3_name"
],
types:[
"string",
"int",
"boolean"
]
}// https://github.com/stimulsoft/DataAdapters.JS/
callback(result);
}
}
进程结束数据
该事件在收到构建报告所需的数据后触发。它在StiReport实例上处理onEndProcessData事件后立即发生。以下是事件处理程序参数的列表 :
{
sender: "Viewer",
event: "EndProcessData",
report: StiReport,command: string,
dataSource: string,
connection: string,
database: string,result: DataSet|any
}
从适配器调整数据的示例:
viewer.onEndProcessData = (args) => {
if (args.command == "ExecuteQuery" && args.dataSource == "Categories")
args.result.rows.push(rowData) ;// https://github.com/stimulsoft/DataAdapters.JS/
}
打印报告
它用于在打印之前修改报告或实现自定义打印功能。
该事件在打印报告之前触发。以下是事件处理程序参数的列表:
{
sender: "Viewer",
event: "PrintReport",
report: StiReport,
preventDefault: boolean,
async: boolean
printAction: string,
}
打印前删除图片的示例:
viewer.onPrintReport = (args) => {
var page = args.report.renderedPages.getByIndex(0);
var image = page.components.getByName("Image1");
if (image)
page.components.remove(image);
}
开始导出报告
它用于在导出之前调整导出设置或修改报告。
该事件在导出报告之前、对话框中指定的导出设置完成之后触发。以下是事件处理程序参数的列表:
{
sender: "Viewer",
event: "BeginExportReport",
report: StiReport
preventDefault: boolean,
async: boolean,
action: StiExportAction,
settings: IStiDashboardExportSettings | StiExportSettings,
format: StiExportFormat,
formatName: string,
fileName: string,
openAfterExport: boolean,
}
调整导出参数的示例:
viewer.onBeginExportReport = (args) => {
if (args.format == Stimulsoft.Report.StiExportFormat.Pdf)
args.settings.imageQuality = 0.5;
}
结束导出报告
用于实现独立的文件保存。
该事件在导出报告之后、保存文件之前触发。以下是事件处理程序参数的列表:
{
sender: "Viewer",
event: "BeginExportReport",
report: StiReport,
preventDefault: boolean,
async: boolean,
action: StiExportAction,
format: StiExportFormat,
formatName: string,
fileName: string,
openAfterExport: boolean,
data: string | number[]
}
更改导出文件名称的示例:
viewer.onEndExportReport = (args) => {
args.fileName = "SampleFileName.txt";
}
交互上
该事件在交互发生之前触发。以下是事件处理程序参数的列表:
{
sender: "Viewer",
event: "Interaction",
report: StiReport,
preventDefault: boolean,
async: boolean,
action: string,
variables,
sortingParameters,
collapsingParameters,
drillDownParameters,
filteringParameters
}
替换变量值的示例:
viewer.onInteraction = (args) => {
if (args.action == "Variables")
args.variables["Variable1"] = "New Value";
}
电子邮件报告
它用于通过电子邮件发送导出的报告。
该事件在通过电子邮件发送报告之前触发。以下是事件处理程序参数的列表:
{
sender: "Viewer",
event: "EmailReport",
report: StiReport,settings: {
email: string;
subject: string;
message: string;
},
format: StiExportFormat,
formatName: string,
fileName: string,
data: number[] | string
}
要启用该按钮,您需要设置以下参数:
viewerOptions.toolbar.showSendEmailButton = true;
发送电子邮件的示例:
viewer.onEmailReport = (args) => {
var emailAddress = args.settings.email;
var emailMessage = args.settings.message;
var emailSubject = args.settings.subject;
var emailAttachmentFileName = args.fileName;
var emailAttachment = args.data;sendEmail(emailAddress, emailMessage, emailSubject, emailAttachmentFileName, emailAttachment);
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。