title: MVC with Kendo treeview - remote data JSON or XML
body: <p>I'm trying to create a Kendo treeview that gets populated from my controller (PropertyController).</p>
  
  <p>The part I'm stuck at is how to format my data in the controller. How could I create a treeview three items deep and pass that to my view to be displayed in the treeview? </p>
  
  <pre><code>@(Html.Kendo().TreeView()
                  .Name("treeview")
                  .Events(events =&gt; events
                                          .DragStart("PartnershipPage.OnDragStart")
                                          .Drop("PartnershipPage.OnDrop")
                                          .DragEnd("PartnershipPage.OnDragEnd")
                    )
                    .HighlightPath(true)
                    .DragAndDrop(true)
                    .DataSource(dataSource =&gt; dataSource
                      .Read(read =&gt; read
                          .Action("Index","Tree")
                      )
                    )
              )
  </code></pre>
  
  <p>I've included the controller to see if I'm doing it correctly. All that is happening so far is the JSON is being displayed on the screen as text.</p>
  
  <p>Controller:</p>
  
  <pre><code>public ActionResult Index()
      {
          var org = new Entities();
          var eList = new List&lt;Entity&gt;();
  
          var entity1 = new Entity
              {
                  Id = 1,
                  Name = "LLC-A",
                  parentId = 0
              };
          eList.Add(entity1);
  
          var entity2 = new Entity
          {
              Id = 2,
              Name = "LLC-B",
              parentId = 0
          };
          eList.Add(entity2);
  
          var entity3 = new Entity
          {
              Id = 1,
              Name = "LLC-C",
              parentId = 2
          };
          eList.Add(entity3);
  
          var entity4 = new Entity
          {
              Id = 1,
              Name = "LLC-D",
              parentId = 2
          };
          eList.Add(entity4);
  
          org.Entity = eList;
  
          var test = from x in org.Entity
                     where (x.Name != null)
                     select new
                         {
                             Id = x.Id,
                             Name = x.Name,
                             parentId = x.parentId
                         };
          ;
  
          return Json(test, JsonRequestBehavior.AllowGet);
      }
  </code></pre>