2012-07-31 43 views
0

這是我在telerik mvc中創建樹的代碼。現在我想創建顯示所選節點名稱的彈出窗口。顯示Telerik MVC中選定的元素TreeView

Html.Telerik().TreeView() 
    .Name("ZebTree") 
    .ExpandAll(true) 
    .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;})); 
      }   
    ) 

這是javascript代碼。

function TreeView_onSelect(e) 
    { 
     var treeview = $(this).data('tTreeView'); 

     alert("You select the node " + ...); 

    } 

回答

1

獲取一個節點的文本:

function TreeView_onSelect(e) 
{ 
    var treeview = $(this).data('tTreeView'); 
    var nodeText = treeview.getItemText(e.item); 
    alert("You select the node: " + nodeText); 
} 

問候