Perpetuum Reports中的报告编辑器

时间:2012-12-29 10:04:54

标签: javascript asp.net-mvc reporting

我正在使用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>

1 个答案:

答案 0 :(得分: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>