2012-08-01 64 views
1
<%: 
    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;})); 
      }   
    ) 
%> 

以上是在telerik mvc中生成樹的代碼。我想通過選擇節點來執行操作。當有人點擊特定節點時,我希望它導航到關於頁面並將該節點的文本作爲參數傳遞給關於頁面。Telerik MVC Treeview Action

+0

你已經有了一個clientevent,你已經提供了代碼。你確切的問題是什麼? – 2012-08-01 04:11:54

+0

西蒙只是它將被調用的事件。我想實現OnSelect事件(TreeView_OnSelect) – 2012-08-01 04:34:10

回答

1

呦傢伙,

其實,有一個叫做行動方法,你可以用它來指定您希望您的項目在行動指向。你可能沒有看到它,因爲intellisence相當混亂。你可以這樣更具體一點:

.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; 
       }) 
    } 

我希望這是你在找什麼。