TreeControl first node selected

I

ilona

Hi,
trying to use Microsoft Treeview control w/dynamically populated nodes.
The problem is that the first node in the tree is always selected and as a
result when user clicks on it, OnSelectionChange event can not fire. So if a
user has permissions to see only one node then he can not do anything with
it.
I would like the tree to display with no nodes selected - so that all of the
nodes that are shown as link work. Do you have any ideas on how to achieve
that? Or maybe you can recommend another tree control (not the microsoft's
one) where this is possible?
Tried:
on page load - TreeControl.SelectedNodeIndex = null or ""; - first node
still gets selected.
 
I

ilona

Alvin, thankyou--
very excited on getting closer - but not there yet :
selectednodeindex must be a string, so put in
TreeCtrl.SelectedNodeIndex="-1";
Got
Invalid node index "-1". Node index must consist of numbers separated by
periods.
tried "0.-1" as well but it would not take that either. It seems to simply
not take -1.
Did you somehow get it to work with -1?

It says this in the help:
The structure of the index returned by this method is a concatentation of
the ordinal number of the parent node at each level counting through the
tree from 0 down to the selected node and delimiting each level with a dot
(.). The uppermost node in the top level of the tree is 0; the second node
is 1, and so on. The node that immediately follows the first top-level node
is 0.0; the second is 0.1, and so on. For example, for the index value
1.3.2, 1 is the second node at the top level of the tree; 3 is the fourth
node under node 1; and 2 is the third node under node 1.3 and it is the
selected node.
 
A

Alvin Bruney

back up a bit, clicking on the node should fire the expand event, that is
where your code needs to go, inside the expand handler, not in the
selectchange because it may fire when you least expect it. If you map to the
expand event, it doesn't matter what is selected.
regards
 
I

ilona

Oh,--
My tree has expand/collapse functionality, but each node is displayed as a
link.
It represents categories and subcategories. When a user clicks on category
or subcategory - onSelectionChanged event fires performing the search for
documents falling into selected category. When a user expands a category,
they see subcategories undeneath.
Here is my tree:
<iewc:treeview id="TreeCtrl" runat="server"
DefaultStyle="color:#FFF;font-family:Arial;font-size:10px;text-decoration:un
derline;" AutoPostBack="True"></iewc:treeview>

In the code from dataset I set id of the node to be CategoryID and node Text
to be Category Name, so the output is like this:

<tvns:treenode Type="category" Target="doc" ID="GeneralInfo"> General
Information
<tvns:treenode Type="subcategory" Target="doc" ID="Operations">
Operations
</tvns:treenode>
<tvns:treenode Type="subcategory" Target="doc" ID="Merchandising">
Merchandising
</tvns:treenode>
</tvns:treenode>

and I simply perform the search based on the ID of the node that the user
clicks on.

So the problem is that by default Tree Control has first node in the tree
(Node with the index of 0) selected like so:
<tvns:treenode Type="category" Selected="true" Target="doc" ID="Fixtures">
Fixtures
</tvns:treenode>

As a result, when the user clicks on it nothing happens (cuz slected status
does not change) - so what I am trying to do is to overwrite this default so
that the first node of the tree is not selected and all of my links are
clickable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top