This is a migrated thread and some comments may be shown as answers.

ScrollIntoView returns 'offsetTop' is null

1 Answer 127 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
David Beck
Top achievements
Rank 1
David Beck asked on 14 Jun 2010, 08:50 PM
Hello,

 I have a Treeview with LoadOnDemand using ServerSideCallback.

I am using a Combobox at the top of the page to act as a quick selector/search when i select a node formt he combo box it selected the node and then expands it.

I then call  the scroolIntoView but i get a JS Error stating offsetTop is null or not an object

 heres the sample code i use for the Combox's SelctionChanged Event

function ddlSearchTreeView_SelectionChanged(sender, eventArgs)   
                {  
                    var _Item = eventArgs.get_item();  
                    var tree = $find("<%=oTreeView.ClientID %>");  
                    var node = tree.findNodeByValue(_Item.get_value());  
                    node.select();  
                    node.expand();  
// HIGH VALUE FOR TESTING  
                    window.setTimeout(function() {node.scrollIntoView(); }, 10000);  
                } 

1 Answer, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 18 Jun 2010, 07:28 AM
Hi Loren Dorez,

You only have to change one line in your code and it should be working fine.
Change:
node.scrollIntoView();
to:
node.get_element().scrollIntoView();

Our "scrollIntoView" is working only for the container of the treeView itself (if you set the height in way to have a scrollBar, than it's going to scroll it to that node), and when you use the one for the dom element of the node, it scrolls all containers so the element becomes visible.

Hope this is going to help you!


Regards,
Nikolay Tsenkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
David Beck
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Share this question
or