gpt4 book ai didi

asp.net-mvc - MVC 中的 SSRS Reportviewer,通过自动调整 iframe 大小以适合报表来删除 iframe 滚动条

转载 作者:行者123 更新时间:2023-12-02 11:58:19 24 4
gpt4 key购买 nike

我拼凑了有关在 iframe 中渲染报表查看器时消除 iframe 滚动条以支持浏览器滚动条的信息。 MVC 不支持在 View 中呈现报表查看器,因此需要 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 - MVC 中的 SSRS Reportviewer,通过自动调整 iframe 大小以适合报表来删除 iframe 滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25031499/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com