views:

549

answers:

1

Reporting Services appears to believe it is being "helpful" by auto-scrolling the web page whenever a user expands a row group by clicking the plus sign. Short of hacking a Microsoft DLL, does anyone know a way to stop this behavior?

Searching around the net, I've found this years-old thread discussing the same issue, but no answer. I was hoping my friends at SO might be a little more knowledgeable.

+1  A: 

Hi,

I've just hit the same issue and put a dirty fix in place!! I'm showing reports in my own custom asp.net page using the report viewer control. That helps me because I can put some additional script in my outer host page. Here's what I did:

I switched on 'MaintainScrollPositionOnPostback' on my page as I'm lazy and just hijack their function to work out the scroll-bars y position.

I set an interval to capture the scroll-bars Y location every 50ms.

I attach an event handler to the load event of the SSRS IFrame which will set the scroll bar back to where it previously was.

When SSRS posts back the iframe load event occurs. At this point SSRS has annoyingly adjusted the scroll bar. My event handler kicks in and puts it back!! It's pretty disgusting but does the job.

Code:

<script language="javascript">


    $(document).ready(function() {

        $('iframe').load(function() {
            resetScrollbar();
        });

    });

    var lastGoodScrollY = 0;
    var interval = window.setInterval(getScrollY, 50);

    function getScrollY() {
        lastGoodScrollY = WebForm_GetScrollY();
    }

    function resetScrollbar() {
        window.scrollTo(0, lastGoodScrollY);
    }

</script>

Hope that helps,

Graeme

Graeme Foster