0

我正在使用Perpetuum Reports在我的应用程序中打印发票。现在我需要允许我的用户打印发票。我应该如何使用hiperlink?

我使用以下代码,但它不起作用:

<script src="@Url.Content("~/Scripts/jquery.treeview.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/mscorlib.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/PerpetuumSoft.Reporting.WebViewer.Client.Model.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/PerpetuumSoft.Reporting.WebViewer.Client.js")" type="text/javascript"></script>

<script type="text/javascript"> 
var reportViewer = null;
$(document).ready(function () 
{ 
    var reportViewer = new PerpetuumSoft.Reporting.WebViewer.Client.ReportViewer("#ReportViewerElement"); 
    reportViewer.setServiceUrl("http://jmanlocal/ReportServiceController"); 
    reportViewer.reportName = "InvoicesRep"; 
    reportViewer.renderDocument(); 
    reportViewer.setThumbnailsControl("#ssr_thumbnailContentPanel"); 
    reportViewer.setDocumentMapControl("#documentMapView"); 
}); 

function PrintRep()
{
    reportViewer.exportToPdf();
}

</script>

<div id="ReportViewerElement"></div>
<button onclick="PrintRep()">Print</button>
4

1 回答 1

0

看起来您的 document.ready 处理程序中有额外的 var 关键字。它为您的处理函数声明局部变量,因此全局 reportViewer 变量不会引用您的报表查看器。所以,这是更正的代码:

<script src="@Url.Content("~/Scripts/jquery.treeview.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/mscorlib.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/PerpetuumSoft.Reporting.WebViewer.Client.Model.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/PerpetuumSoft.Reporting.WebViewer.Client.js")" type="text/javascript"></script>

<script type="text/javascript"> 
var reportViewer = null;
$(document).ready(function () 
{ 
    reportViewer = new PerpetuumSoft.Reporting.WebViewer.Client.ReportViewer("#ReportViewerElement"); 
    reportViewer.setServiceUrl("http://jmanlocal/ReportServiceController"); 
    reportViewer.reportName = "InvoicesRep"; 
    reportViewer.renderDocument(); 
    reportViewer.setThumbnailsControl("#ssr_thumbnailContentPanel"); 
    reportViewer.setDocumentMapControl("#documentMapView"); 
}); 

function PrintRep()
{
    reportViewer.exportToPdf();
}

</script>

<div id="ReportViewerElement"></div>
<button onclick="PrintRep()">Print</button>
于 2013-01-21T03:30:05.120 回答