将Treeview选定的节点滚动到div的中间 [英] scroll treeview selected node into middle of div

查看:64
本文介绍了将Treeview选定的节点滚动到div的中间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Asp.net Web应用程序
我有一个div(div是可滚动的),在此div中有一个treeview.
我想将选定的Treeview节点滚动到div的中间.

通过使用selectednode.scrollintoview(true),我可以在div顶部滚动选定的节点.
但我的要求是在div的中间滚动/显示该节点.

div.scrolltop =(div.scrollheight-div.clientheight)* 0.5
这行代码将div滚动到中间,但是我想将选定的节点滚动到中间.

请尽快帮助我.
自3天以来,我一直在为此苦苦挣扎.

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.

推荐答案

您应该将执行div.scrolltop的滚动应用于树形视图控件.
一旦执行了selectednode.scrollintoview(true)调用,就可以通过偏移树视图的滚动位置来增加父div高度的一半.
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.


这篇关于将Treeview选定的节点滚动到div的中间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆