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

RadTreeView, XML, only want final child nodes to trigger NodeClick event (server side) - help!

3 Answers 109 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 08 Feb 2012, 11:49 PM
I am prototyping a new project where users will navigate a dynamically generated list of hierarchically nested assets (bound to a RadTreeView). I want the users to be able to drill down into the tree to the actual asset item in the list. On clicking the asset item:

1. I want to reload the page using the ID VALUE (not the text displayed) of the item clicked. This will load all sorts of unique info for that item. I was going to simply use querystring variables so the users can bookmark their searches. I'd like to grab the selected ID, put it in querystring, and reload the page. What's the best practice for having an ID VALUE attached to a node (in XML)? What is the best way to access it in C#?

2. I also want to persist on refresh what the user clicked, so it the selected item is active (because navigating thousands of items all over again isn't acceptable). We're dealing with a nationwide list of assets.

3. I DON'T want anything to cause a postback except the final child element in the hierarchy. How do I control what causes postback and what doesn't in a dynamically generated RadTreeView list of items?

Please provide sample code if you can. NOTE: For the prototype, I've already connected to an XML file using the .LoadContentFile() method. I'm using dummy data to get started.

Thanks much for your assistance!
A

3 Answers, 1 is accepted

Sort by
0
Alex
Top achievements
Rank 1
answered on 09 Feb 2012, 05:09 PM
I figured out how to do everything for #1 and #2. I'm still stuck on #3. I don't want any of the parent nodes in the tree to allow postback... just the final item in the hierarchy.

Can anyone please provide some tips on ways to do this?
A
0
Bozhidar
Telerik team
answered on 10 Feb 2012, 10:04 AM
Hi Alex,

Could you be a little more specific, as to how exactly are you causing a postback from the TreeNodes? If you are just refering to clicking a node, you can cancel this in the OnClientNodeClicking event. Here's an example:
function clientNodeClicking(sender, args) {
    var node = args.get_node();
    //check if it is a last node
    if (node.get_nodes().get_count() > 0) {
        args.set_cancel(true);
    }
}

 
Kind regards,
Bozhidar
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Alex
Top achievements
Rank 1
answered on 10 Feb 2012, 09:05 PM
I decided to just use the NodeClick server side event. If there is a value for the node, then the app will process data based on the value (an ID). For parent nodes, we don't set any value, just the text.

I do like the client side approach you provided. I'll check it out!

Thanks.
A
Tags
TreeView
Asked by
Alex
Top achievements
Rank 1
Answers by
Alex
Top achievements
Rank 1
Bozhidar
Telerik team
Share this question
or