Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Scroll a node into view -- ASPNET 2.0 Treeview

Reply
Thread Tools

Scroll a node into view -- ASPNET 2.0 Treeview

 
 
William Sullivan
Guest
Posts: n/a
 
      04-25-2006
Anybody figure this out? I can't figure out how to get the node's client
side control ID in order to grab aholt of it. I've seen a post that says
that the node's ID is: TreeView.ID + (index of the TreeNode in
TreeView.Nodes collection). The problem is that, even after a postback, you
can't get the index of the treenode in the collection. You'd think that this
would work:
(after SelectedNodeChanged postback)
TreeView.Nodes.IndexOf(TreeView.SelectedNode)
--or--
(when you have the ValuePath)
TreeView.Nodes.IndexOf(TreeView.FindNode(ValuePath ))

Both of which return -1 for the node index. So what's the solution?

 
Reply With Quote
 
 
 
 
William Sullivan
Guest
Posts: n/a
 
      06-09-2006
Placing the solution here for future reference:

The TreeView creates an object in Javascript on the client side that's called
[treeview name]_Data
i.e., if the treeview is named tvNavigation, the object's name would be
tvNavigation_Data
This object has a property called selectedNodeID. This property has a ...
property called value that contains the id of the currently selected node. So

var name = tvNavigation_Data.selectedNodeID.value;
var selectedNode =
Document.all?Document.all[name]ocument.getElementById(name);
if(selectedNode){ selectedNode.scrollIntoView(true); }

will scroll the currently selected node into view.


"William Sullivan" wrote:

> Anybody figure this out? I can't figure out how to get the node's client
> side control ID in order to grab aholt of it. I've seen a post that says
> that the node's ID is: TreeView.ID + (index of the TreeNode in
> TreeView.Nodes collection). The problem is that, even after a postback, you
> can't get the index of the treenode in the collection. You'd think that this
> would work:
> (after SelectedNodeChanged postback)
> TreeView.Nodes.IndexOf(TreeView.SelectedNode)
> --or--
> (when you have the ValuePath)
> TreeView.Nodes.IndexOf(TreeView.FindNode(ValuePath ))
>
> Both of which return -1 for the node index. So what's the solution?
>

 
Reply With Quote
 
 
 
 
William Sullivan
Guest
Posts: n/a
 
      06-09-2006
The TreeView creates an object in Javascript on the client side that's called
[treeview name]_Data
i.e., if the treeview is named tvNavigation, the object's name would be
tvNavigation_Data
This object has a property called selectedNodeID. This property has a ...
property called value that contains the id of the currently selected node. So

var name = tvNavigation_Data.selectedNodeID.value;
var selectedNode =
Document.all?Document.all[name]ocument.getElementById(name);
if(selectedNode){ selectedNode.scrollIntoView(true); }

will scroll the currently selected node into view.

"William Sullivan" wrote:

> Anybody figure this out? I can't figure out how to get the node's client
> side control ID in order to grab aholt of it. I've seen a post that says
> that the node's ID is: TreeView.ID + (index of the TreeNode in
> TreeView.Nodes collection). The problem is that, even after a postback, you
> can't get the index of the treenode in the collection. You'd think that this
> would work:
> (after SelectedNodeChanged postback)
> TreeView.Nodes.IndexOf(TreeView.SelectedNode)
> --or--
> (when you have the ValuePath)
> TreeView.Nodes.IndexOf(TreeView.FindNode(ValuePath ))
>
> Both of which return -1 for the node index. So what's the solution?
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Functionality to scroll into view? (autoamtically scroll to contentsin the bottom right corner of a large web page) crazychrisy54@hotmail.com Javascript 8 12-20-2007 08:28 AM
Functionality to scroll into view? (autoamtically scroll to contentsin the bottom right corner of a large web page) crazychrisy54@hotmail.com Javascript 0 12-19-2007 02:09 PM
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM
How to drag a sub-node to another node in TreeView? wolf ASP .Net 0 08-18-2004 11:51 PM



Advertisments