Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
255
Preserve grid scroll position inside an UpdatePanel
posted

Hello,

 

I would like to preserve a grid's vertical scroll position across asynchronous postbacks.

 

I have an Infragistics UltraWebGrid control inside a div, which is inside an UpdatePanel, on a page with 4 UpdatePanel controls.   Each UpdatePanel has UpdateMode = Conditional and I will typically .Update() 3 or 4 of the UpdatePanels during the same event.   I want to either remember or reset the vertical scroll position across asynchronous postbacks.  Setting the grid's div.scrollTop value  works.  The problem is scrollTop gets reset back to 0 on asynchronous postbacks by line 1321, "window.scrollTo(...)" in  function "Sys$WebForms$PageRequestManager$_scriptsLoadComplete" in file "MicrosoftAjaxWebForms.debug.js".  I have currently kludged the code using a setTimeout("...grid.DivElement.scrollTop = ...", 100);, which I call from the  Sys.WebForms.PageRequestManager's endRequestHandler.  The timeout was the only way I could find to set scrollTop to execute after line 1321 above.  On aysnchronous postbacks, you can see the scroll position get reset to zero (line 1321), then scroll to the correct position.

Ideally, I would like to prevent line 1321 from executing.  I have tried, to no avail, setting the pageRequestManager._scrollPosition to null  during various events, (pageLoaded, initializeRequest, beginRequest, endRequest).  However, if line 1321 must execute, then I would like to apply my scrollTop code w/o using the setTimeout function since I suspect the timeout duration that works on my machine may not work on slower or busier machines.

 

Does anyone have any suggestions?

 

-Greg Peters