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

[Solved] How to set an action to a treeview?

2 Answers 40 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Leon Ren
Top achievements
Rank 1
Leon Ren asked on 25 Apr 2010, 04:23 AM
I wrote the code below:

 <%= Html.Telerik().TreeView()  
       .Name("TreeView")  
       .Items(items => 
       {  
           items.Add().Text("Item 1").Items(subItem=> 
               {  
                   subItem.Add().Text("subItem1").Action("Create", "Contact") ;  
               });  
           items.Add().Text("Item 2").Url("http://www.baidu.com").HtmlAttributes(new { alt = "Baidu" });  
           items.Add().Text("Item 3");  
       })  
    %> 

I expect that when I click "subItem1" I can navigate to my controller action, and when I click "Item 2" I can navigate to website http://www.baidu.com.

Item2 responsed exactly what i thought, but subItem1 even didn't appear in the browser. Is there something wrong with my code? or how can I implement that ?

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 26 Apr 2010, 11:00 PM
Hello Leon Ren,

The subitem1 will not be rendered if the url generated from the Action and Controller name is not accessible. Please verify that the link is accessible out of the menu. For instance the Action method can be decorated with Authorize attribute which will restrict its accessibility.

Greetings,
Georgi Krustev
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.
0
Leon Ren
Top achievements
Rank 1
answered on 27 Apr 2010, 02:23 AM
I solved the problem now.

I think I should not put that code in Site.master. When I moved it from Site.master to my view page, it started to work.

And your answer is quite right, I also have meet that before.
Tags
TreeView
Asked by
Leon Ren
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Leon Ren
Top achievements
Rank 1
Share this question
or