This question is locked. New answers and comments are not allowed.
I want to implement the telerik MVC Tree view using the Accessiblity Binding example.In the Telerik Demo Examples.
I need the code snippets for Controller,View, and Respective Models required for Employee table data in NorthWind Database.
My Request is to implement a n -level tree view with self referencing heirarchy using the same heirarchy format of Employee table.
I referred the code mentioned in the example.But it is giving some errors.
I am using the LinQ to SQL
View
----------------------------
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Employee>>" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Accessibility123</h2>
<%= Html.Telerik().TreeView()
.Name("TreeView")
.BindTo(Model, mappings =>
{
mappings.For<Employee>(binding => binding
.ItemDataBound((item, employee) =>
{
item.Text = employee.FirstName + " " + employee.LastName;
item.Url = Url.Action("Accessibility", "Home", new { employeeName = employee.FirstName + " " + employee.LastName });
//item.Expanded = true;
})
.Children(category => category.Employees));
})
%>
</asp:Content>
Controller
---------------------------
public ActionResult Accessibility(string employeename)
{
TreeViewModel tvm = new TreeViewModel();
return View(tvm.GetRootEmployees());
}
Model
---------------------------------------------------
public class TreeViewModel
{
public IEnumerable<Employee> GetRootEmployees()
{
TestTelerikTreeDataContext ttdc = new TestTelerikTreeDataContext();
return ttdc.Employees.Where(e => e.ReportsTo == null);
}
}
----------------------------------------------------------------------
Error Page:
I need the code snippets for Controller,View, and Respective Models required for Employee table data in NorthWind Database.
My Request is to implement a n -level tree view with self referencing heirarchy using the same heirarchy format of Employee table.
I referred the code mentioned in the example.But it is giving some errors.
I am using the LinQ to SQL
View
----------------------------
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Employee>>" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Accessibility123</h2>
<%= Html.Telerik().TreeView()
.Name("TreeView")
.BindTo(Model, mappings =>
{
mappings.For<Employee>(binding => binding
.ItemDataBound((item, employee) =>
{
item.Text = employee.FirstName + " " + employee.LastName;
item.Url = Url.Action("Accessibility", "Home", new { employeeName = employee.FirstName + " " + employee.LastName });
//item.Expanded = true;
})
.Children(category => category.Employees));
})
%>
</asp:Content>
Controller
---------------------------
public ActionResult Accessibility(string employeename)
{
TreeViewModel tvm = new TreeViewModel();
return View(tvm.GetRootEmployees());
}
Model
---------------------------------------------------
public class TreeViewModel
{
public IEnumerable<Employee> GetRootEmployees()
{
TestTelerikTreeDataContext ttdc = new TestTelerikTreeDataContext();
return ttdc.Employees.Where(e => e.ReportsTo == null);
}
}
----------------------------------------------------------------------
Error Page: