asp.net-mvc – MVC中的SSRS Reportviewer,通过自动调整iframe以
发布时间:2020-12-16 09:40:42 所属栏目:asp.Net 来源:网络整理
导读:在iframe中呈现reportviewer时,我已经拼凑了有关消除iframe滚动条的信息,转而使用浏览器滚动条. MVC不支持在视图中呈现报表查看器,因此需要iframe. 编辑:我努力找到这个解决方案(下面),因此我想我会分享. 在aspx页面(将在iframe中呈现的页面) $(function ()
在iframe中呈现reportviewer时,我已经拼凑了有关消除iframe滚动条的信息,转而使用浏览器滚动条. MVC不支持在视图中呈现报表查看器,因此需要iframe.
编辑:我努力找到这个解决方案(下面),因此我想我会分享. 在aspx页面(将在iframe中呈现的页面) $(function () {//jQuery document.ready // attach an event handler,whenever a 'property' of the reportviewer changes,the function will be called to adjust the height of the iframe Sys.Application.add_load(function () { $find("ReportViewer").add_propertyChanged(viewerPropertyChanged); // $.find("ReportViewer") will return the reportviewer with id "ReportViewer" }); function adjustIframeSize() { // you can play around with these figures until your report is perfect var extraHeightToAvoidCuttingOffPartOfReport = 100; var extraWidthToAvoidCuttingOffPartOfReport = 10; // '#ReportViewer_fixedTable' is a portion of the report viewer that contains the actual report,minus the parameters etc var reportPage = $('#ReportViewer_fixedTable'); // get the height of the report. '#ParametersRowReportViewer' is that top part that contains parameters etc var newHeight = reportPage.height() + $('#ParametersRowReportViewer').height() + extraHeightToAvoidCuttingOffPartOfReport; // same for width var newWidth = reportPage.width() + extraWidthToAvoidCuttingOffPartOfReport; // get iframe from parent document,the rest of this function only works if both the iframe and the parent page are on the same domain var reportIframe = $('#ReportViewerFrame',parent.document); // just make sure that nothing went wrong with the calculations,other wise the entire report could be given a very small value for height and width,thereby hiding the report if(newHeight>extraHeightToAvoidCuttingOffPartOfReport) reportIframe.height(newHeight); if (newWidth > extraWidthToAvoidCuttingOffPartOfReport) reportIframe.width(newWidth); } function viewerPropertyChanged(sender,e) { // only change the iframe dimensions when 'isLoading' if (e.get_propertyName() == "isLoading") { if (!$find("ReportViewer").get_isLoading()) { adjustIframeSize(); } } }; }); 解决方法
在
ReportViewer for MVC中使用一组扩展解决了类似的问题.
@Html.ReportViewer( ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer,new { scrolling = "no" }) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – Web API和AngularJS SPA应用程序的身份验证
- asp.net-mvc – 在Razor中输出单引号生成的JavaScript字符串
- asp.net-mvc – 自动发现automapper配置
- asp.net – Javascript之前asp:ButtonField点击
- asp.net-web-api – 带有json有效负载中令牌的WebApi授权过
- asp.net – 文件上传控件HasFile始终为false,name始终为Emp
- asp.net-mvc – Kendo DateTimePicker设置当前小时12:00 AM
- asp.net – 为什么在web.config中保存动态数据是个坏主意?
- asp.net-mvc – 如何将我的视图模型绑定到jqGrid?
- asp.net 发布WebService出现的各种问题及解决方法
推荐文章
站长推荐
热点阅读