Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Asp.net web application
I have one div (div is scrollable), inside this div there is a treeview.
I want to scroll selected treeview node into middle of div.

By using selectednode.scrollintoview(true), I am able to scroll selected node on top of div.
but my requirement is to scroll/show that node in middle of div.

div.scrolltop = (div.scrollheight - div.clientheight) * 0.5
this line of code, scrolls the div into middle, but i want to scroll selected node into middle.

Kindly help me out ASAP.
I am struggling with this since 3 days.
Posted
Comments
shivanichhabra 30-Jan-12 7:58am    
Please help me out with this
I am doing this
jQuery(myDiv).scrollTo(selectednode);

this is also not working..please help me out

1 solution

You should apply the scrolling where you do the div.scrolltop to the treeview control instead.
Once you do the selectednode.scrollintoview(true) call, you follow that up by offsetting the scrollposition of the treeview to add half the height of the parent div.
 
Share this answer
 
Comments
shivanichhabra 26-Jan-12 5:32am    
I have tried a lot..but could not, could you please let me know exact lines of code
shivanichhabra 27-Jan-12 9:22am    
I am doing this
jQuery(myDiv).scrollTo(selectednode);

this is also not working..please help me out

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900