telerik中的Treeview控件

时间:2011-12-13 10:16:44

标签: c# asp.net-mvc-3 treeview telerik-mvc

我正在使用asp.net mvc 3.我在我的应用程序中使用Teleric Controls作为Tree视图结构。我想在Controller中构建/构建树视图。并将其填充到其视图中。 一些如何在Controller中准备Tree视图并传递给View的最佳方法或者我可以使用Teleric Tree视图对象模型,构建树并将其传递给View vai ViewData。但是如何将ViewData转换为Telerik Treeview Control?

1 个答案:

答案 0 :(得分:0)

  

Html.Telerik()。TreeView的()   .NAME( “树视图”)   .BindTo((IEnumerable)ViewData [“Customers”],mappings =>
  {
                  mappings.For(binding => binding
                          .ItemDataBound((item,customer)=>
                          {
                              item.Text = customer.ContactName;
                              item.Expanded =((string [])ViewData [“ExpandedNodes”])
                                                 。载(item.Text);
                          })
                          .Children(customer => customer.Orders));

     
    

})
    .ClientEvents(events => events
    .OnCollapse( “updateTreeViewState”)
    .OnExpand(“updateTreeViewState”)

  

取自 http://www.telerik.com/support/kb/aspnet-mvc/treeview/persisting-treeview-state-in-cookie.aspx