Reputation: 1209
<%:
Html.Telerik().TreeView()
.Name("ZebTree")
.ExpandAll(false)
.ClientEvents(events => events.OnSelect("TreeView_onSelect"))
.BindTo(Model , map =>
{
map.For<TreeViewBind.Models.Category>(bind => bind.ItemDataBound((item, category) => { item.Text = category.CategoryName; }).Children(category => category.Products));
map.For<TreeViewBind.Models.Product>(bind => bind.ItemDataBound((item, product) => { item.Text = product.ProductName;}));
}
)
%>
Above is the code for generating tree in telerik mvc. I want to perform action by selecting the node. When somebody click on specific node i want it to navigate to about page and passing the text of that node as argument to about page.
Upvotes: 1
Views: 2967
Reputation: 20203
Yo guys,
Actually there is a method called Action which you can use to specify the action which you want your item to point to. You probably don't see it because the intellisence is quite confused. You can be a bit more specific like this:
.BindTo(Model,(NavigationBindingFactory<TreeViewItem> mappings) =>
{
mappings.For<Category>(binding => binding
.ItemDataBound((item, category) =>
{
item.Action("Test", "Home", new{text=category.CategoryName});//here you can assign the action method , the last parameter is the route values
item.Text = category.CategoryName;
})
}
I hope this is what you are looking for.
Upvotes: 1
Reputation: 65079
OnSelect prototype:
function TreeView_onSelect(e) {
}
The e only has 1 element, "item", which is the LI element that's been selected. So, an example would be:
function TreeView_onSelect(e) {
alert($(e.item).text());
}
Upvotes: 2