This is a migrated thread and some comments may be shown as answers.

Telerik MVC Tree View Accessbility Binding Example

0 Answers 68 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Narayana
Top achievements
Rank 1
Narayana asked on 24 Jan 2012, 02:56 AM
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:







Tags
TreeView
Asked by
Narayana
Top achievements
Rank 1
Share this question
or