troubleshooting Question

Programmatically position gridview/table scrolling

Avatar of codequest
codequest asked on
ASP.NET
5 Comments1 Solution2786 ViewsLast Modified:
I've got a gridview that's going to be scrolled vertically in a <div>.  In another sub-form on the same page, the user will select a record identifier that corresponds to a row in the gridview.

When the user chooses that record identifier, I need to figure out a way to cause the particular corresponding row in the gridview to be positioned within the visible area of the scrolling <div> (because it might be "above" or "below" that visible area).  Ideally the particular would be positioned at the top of the visible gridview rows...but that's probably a detail in this general solution.

I expect this will all be done in javascript.   I see that scrollTop can be set as well as gotten, and that's likely to be a key property in doing this.  

The gap seems to be knowing what value to set scrollTop to.  This could possibly be a calculation based on known row height, and row positional count (provided the rows didn't vary in height...but even that could be probably be dealt with.)

Unless there's a way to get relative row position, as in {x = rowVar.style.top} (which I'm not sure exists for rows, or would have to be somehow declared in advance?)...because that could be immediately combined mathemagically with scrollTop.

Any suggestions on how to make this work would be appreciated.

Thanks!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros