Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET 2.0 TreeView - Programatically Selecting A TreeView Node

Reply
Thread Tools

ASP.NET 2.0 TreeView - Programatically Selecting A TreeView Node

 
 
=?Utf-8?B?VHltYm93?=
Guest
Posts: n/a
 
      01-08-2006
I'm building a web application that is analogous to the Windows XP file
explorer in function. The left column contains a TreeView, and the right
column a DataGrid populated by selecting TreeView nodes. The TreeView
populates dynamically as there are a significant number of nodes. The
DataGrid displays both the items and the nodes from the TreeView. Using the
explorer analogy this means the TreeView shows folders, and the DataGrid
folders and files.

The issue I have is that I would like to be able to update the TreeView to
show the selected node if the user selects the matching node from the
DataGrid. Again with the Explorer analogy, if the user selected a folder, the
folder tree would update to match the change. I'm not sure it's possible due
to the dynamic nature of the TreeView in this example as the node may not
even exist in the nodes collection (eg: The TreeView shows the root node plus
1 level but the user has drilled down 3 levels in the DataGrid from the root
node).

Any suggestions?

Kind Regards,
Tim.
 
Reply With Quote
 
 
 
 
Koen Hakvoort
Guest
Posts: n/a
 
      01-08-2006
Hello Tim,

Maybe you could try something like this
Check if a folder item is selected in a datagrid item in the
selectedindexchanged event. If so expand the folder Node in the treeview
with findnode and expand
Treeview1.FindNode("Authors\\Shakespeare").Expand( ); or Select

I hope this contributes to a solution.

regards,

Koen Hakvoort



"Tymbow" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm building a web application that is analogous to the Windows XP file
> explorer in function. The left column contains a TreeView, and the right
> column a DataGrid populated by selecting TreeView nodes. The TreeView
> populates dynamically as there are a significant number of nodes. The
> DataGrid displays both the items and the nodes from the TreeView. Using
> the
> explorer analogy this means the TreeView shows folders, and the DataGrid
> folders and files.
>
> The issue I have is that I would like to be able to update the TreeView to
> show the selected node if the user selects the matching node from the
> DataGrid. Again with the Explorer analogy, if the user selected a folder,
> the
> folder tree would update to match the change. I'm not sure it's possible
> due
> to the dynamic nature of the TreeView in this example as the node may not
> even exist in the nodes collection (eg: The TreeView shows the root node
> plus
> 1 level but the user has drilled down 3 levels in the DataGrid from the
> root
> node).
>
> Any suggestions?
>
> Kind Regards,
> Tim.



 
Reply With Quote
 
 
 
 
=?Utf-8?B?VHltYm93?=
Guest
Posts: n/a
 
      01-10-2006
That helped. Thanks.

FYI it can be done but it gets a little ugly. Due to the dynamic nature of
the treeview you must remember to use select() and expand() when you change
nodes outside of the tree or things can get very lost. I didn't have much
luck with find node and ended up just iterating the child nodes looking for a
ValuePath match but I'll try to get FindNode working (I hate text matching -
very ugly and requires too much support code to handle unexpected input).

"Koen Hakvoort" wrote:

> Hello Tim,
>
> Maybe you could try something like this
> Check if a folder item is selected in a datagrid item in the
> selectedindexchanged event. If so expand the folder Node in the treeview
> with findnode and expand
> Treeview1.FindNode("Authors\\Shakespeare").Expand( ); or Select
>
> I hope this contributes to a solution.
>
> regards,
>
> Koen Hakvoort
>
>
>
> "Tymbow" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I'm building a web application that is analogous to the Windows XP file
> > explorer in function. The left column contains a TreeView, and the right
> > column a DataGrid populated by selecting TreeView nodes. The TreeView
> > populates dynamically as there are a significant number of nodes. The
> > DataGrid displays both the items and the nodes from the TreeView. Using
> > the
> > explorer analogy this means the TreeView shows folders, and the DataGrid
> > folders and files.
> >
> > The issue I have is that I would like to be able to update the TreeView to
> > show the selected node if the user selects the matching node from the
> > DataGrid. Again with the Explorer analogy, if the user selected a folder,
> > the
> > folder tree would update to match the change. I'm not sure it's possible
> > due
> > to the dynamic nature of the TreeView in this example as the node may not
> > even exist in the nodes collection (eg: The TreeView shows the root node
> > plus
> > 1 level but the user has drilled down 3 levels in the DataGrid from the
> > root
> > node).
> >
> > Any suggestions?
> >
> > Kind Regards,
> > Tim.

>
>
>

 
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
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
Programmatically selecting a node in a TreeView dhurwitz ASP .Net Web Controls 0 06-13-2006 02:34 PM
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
Treeview Web Control - selecting a node Rod Early ASP .Net Web Controls 2 12-15-2003 03:12 PM
Treeview- programatically select a Node Liliana García ASP .Net Web Controls 3 07-18-2003 07:12 PM



Advertisments