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

OnNodeClick event

3 Answers 220 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Yanling
Top achievements
Rank 1
Yanling asked on 09 Oct 2008, 04:13 AM
Hi Telerik,

I have a radtreeview which is dynamically binded to database. Following is the table structure:

AreaId | ParentAreaId | AreaName | IsRoomLevel | IsExpanded

1. When the treeview is generated, I want to assignment the "OnNodeClick" event only to the nodes whose attribute IsRoomLevel = 'True', i.e. not all the nodes can trigger the OnNodeClick event. How to achieve this?

2. When the "OnNodeClick" event is on, the nodes cannot be double clicked to expand or shrink because the page will refresh when the node is clicked.

3. I want to save the status of the treeview, i.e. the expend status of each node. But it is not efficient if I save the status of all the nodes to the database every time the their status are changed.

Any suggestions for these three questions? Thanks!

Best regards,
Hank

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 09 Oct 2008, 01:35 PM
Hello Yanling,

Here are the answers to your questions:

1. You need to subscribe the whole treeview to the NodeClick server-side event. Then you need to subscribe to the OnClientNodeClicking client-side event and cancel it if the "IsRoomLevel" attribute of the node is not true.

2. In the NodeClick event handler you can change the Expanded state of the clicked node:

e.Node.Expanded = !e.Node.Expanded; 

3. You can save the status of the expanded nodes on postback and not on every client expand / collapse.
You can use the GetXml() method of the treeview for that.

I hope this helps.

Sincerely yours,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
adnan
Top achievements
Rank 1
answered on 15 Jul 2010, 02:23 PM
Ok i am having a similar problem but my scenario is different

i have three hierarchies

H1, H2, H3
what i want is when i click on H1 i will redirect to page 1
when i click on H2 i will redirect to page 2
when i click on H3 i will redirect to page 3

so how can i see i which hierarchy i am in so that i can call the right redirect method?
0
Nikolay Tsenkov
Telerik team
answered on 16 Jul 2010, 02:04 PM
Hi adnan,

First, you can not have different dataSources for one instance of the TreeView, if you do - you need to either:
1. Join them (if is a SQL data source make a SQL JOIN for example);
2. Create custom data binding method that should load the data from different sources and create nodes accordingly.

Then, you can handle the NodeDataBound event and there to apply the appropriate NavigateUrl.

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
Yanling
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
adnan
Top achievements
Rank 1
Nikolay Tsenkov
Telerik team
Share this question
or