This example shows how to use the report viewer events. Some viewer actions have events to which you can subscribe. For example, print action, begin of the export, design report:
<script type="text/javascript">
	// Enable the design button
	var options = new Stimulsoft.Viewer.StiViewerOptions();
	options.toolbar.showDesignButton = true;

	// Create the report viewer
	var viewer = new Stimulsoft.Viewer.StiViewer(options, "StiViewer", false);

	// Assign the onGetReportData event function
	viewer.onBeginProcessData = function (args) {
		var ds = new Stimulsoft.System.Data.DataSet("Demo");
		ds.readJsonFile("../reports/Demo.json");
		args.report.regData("Demo", "Demo", ds);
	}

	// Assign the onPrintReport event function
	viewer.onPrintReport = function (args) {

	}

	// Assign the onBeginExportReport event function
	viewer.onBeginExportReport = function (args) {
		switch (args.format) {
			case "Html":
				args.settings.zoom = 2;  // Set HTML zoom factor to 200%
				break;
		}
	}

	// Assign the onReportDesign event function
	viewer.onDesignReport = function (args) {
		alert("Design button presed.");
	}

	// Create a new report instance
	var report = new Stimulsoft.Report.StiReport();
	// Load report from url
	report.loadFile("../reports/SimpleList.mrt");
	// Assign report to the viewer, the report will be built automatically after rendering the viewer
	viewer.report = report;

	// Show the report viewer in the 'content' element
	viewer.renderHtml("content");
</script>

Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:

Using Viewer Events

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.