您好,
这是一个自定义的按钮。需要增加前端代码。- <script src="http://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
- <script language="javascript" type="text/javascript">
- function ForcePostBack() {
- form1.submit();
- }
- function printreport() {
- viewModel.Print();
- }
- var reportSelect = '<select id="ReportSelect" style="width:150px"><option selected disabled>Choose Report</option><option value="SectionReport1">SectionReport1</option><option value="SectionReport2">SectionReport2</option><option value="RdlReport1">RdlReport1</option></select>';
- var exportSelect = '<select id="ExportSelect" style="width:80px"><option selected disabled>Export</option><option value="PDF" style="background: url(images/pdf.png) right no-repeat; width: 50px">PDF</option><option value="Excel" style="background: url(images/Excel.gif) right no-repeat; width: 50px">Excel</option></select>';
- var printBtn = '<span><input id="btnPrint" type="Button" value="Print" onclick="print()"/></span>';
- $(document).ready(function () {
- var selectedValue = $("#fldReportName").val();
- if (selectedValue !== "") {
- setTimeout(function () {
- $("#ReportSelect").val(selectedValue);
- }, 100);
- }
- var toolbar = $('#WebViewer1').find('.arvToolBar');
- toolbar.append(reportSelect);
- toolbar.append(exportSelect);
- toolbar.append(printBtn);
- var viewModel = GetViewModel("WebViewer1");
- //Force a postback upon report selection
- $("#ReportSelect").change(function (e, args) {
- var reportName = this.value;
- $("#fldReportName").val(reportName);
- ForcePostBack();
- this.value = $("#fldReportName").val();
- });
- function print() {
- viewModel.Print();
- };
- //Check the selected value in DropDown and Export
- $("#ExportSelect").change(function (e, args) {
- var valueSelected = this.value;
- if (viewModel.PageLoaded()) {
- switch (valueSelected) {
- case "PDF":
- viewModel.Export(ExportType.Pdf, function (uri) {
- window.location = uri;
- }, true);
- break;
- case "Excel":
- viewModel.Export(ExportType.Xls, function (uri) {
- window.location = uri;
- }, true);
- break;
- }
- }
- });
- });
- </script>
复制代码 |