调用 Reporting Service 时,怎么去掉滚动条。

用Reporting Service 制作各种报表,是一个不错的选择,但是不管你使用Asp.Net Web Form 还是使用Mvc对其调用时,总是会发现,多出一层滚动条,若你适当调节窗口大小,甚至能发现内外三层滚动条,怎么办?使用Jquery 来去掉他

以下是我自己的项目中去掉滚动条的代码,贴出来,供大家分享,大家可以参照他,去掉自己项目中的滚动条

1、Asp.Net Web Form  【Asp.Net Web Form 调用Reporting Service 】

WebFormReportViewStyle.js 

$(document).ready(function() {                                                 

    FormAjust();                                                               

});                                                                           

function FormAjust() {                                                         

    var oReportDiv = $("div[id$='oReportDiv']");                               

    var constheight = 15;                                                      

                        oReportDiv.css("overflow", "hidden");                                    

                        var innerDiv = $(oReportDiv).find("div").get(0);                         

                        var table = $(oReportDiv).find("table").get(0);                          

                        var tableHeight = $(table).attr("offsetHeight");                         

                                                                                                 

                        var tableDiv = $(table).find("div").get(0);                              

                        var tableWidth = $($(tableDiv).find("table").get(0)).attr("offsetWidth");

                        $(innerDiv).css("height", tableHeight + constheight);                    

                        $(innerDiv).css("width", tableWidth + constheight * 6);                  

}

2、mvc 1.0/2.0 【Mvc调用Reporting Service

MVCReportViewStyle.js 

$(document).ready(function() {

    if (window.frames["ReportFramectl00_MainContent_ReportViewer1"] != undefined) {

        timeSet();

    }

});

function timeSet() {

    var frameset = $(window.frames["ReportFramectl00_MainContent_ReportViewer1"].document).find("frame").get(1);

    if (frameset != undefined && frameset.contentWindow.document.readyState == "complete") {

        formatAdjust();

    }

    else {

        setTimeout("timeSet()", 500);

    }

}

function formatAdjust() {

    var frameset = $(window.frames["ReportFramectl00_MainContent_ReportViewer1"].document).find("frame").get(1);

    $(frameset).bind("load", timeSet);

    $(frameset.contentWindow.document.body).css("overflow", "hidden"); //去掉外侧滚动条

    var reportdiv = $(frameset.contentWindow.document).find("#oReportDiv");

    reportdiv.css("overflow-y", "hidden"); //去掉内侧滚动条

    var constNumber = 15;

    var tableHeight = $($(reportdiv).find("table").get(0)).attr("offsetHeight");

    var frameTop = $($("iframe").get(0)).attr("offsetTop");

    var mainTop = $("div[id='main']").attr("offsetTop");

 

    var diff = frameTop - mainTop;

    var mainHeight = diff + tableHeight;

 

    $($("iframe").get(0)).css("height", tableHeight + constNumber);

    $("div[id='main']").css("height", mainHeight + constNumber);

}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值