2013-03-02 3 views
2

첫 번째로드시 모든 노드를 표시하는 검도 TreeView을 만들고 싶습니다. Kendo 'Binding to remote data'샘플을 사용하고 있지만 제대로 작동하지 않습니다. 그것은 단지 첫 번째 레벨을 보여 주며 컨트롤러 액션에 전달 된 ID는 항상 null입니다. 도와주세요.검도 UI 트리 뷰 바인딩

보기 코드 :

@(Html.Kendo().TreeView() 
    .Name("treeview") 
    .DataTextField("Title") 
    .ExpandAll(true) 
    .LoadOnDemand(false) 
    .DataSource(dataSource => dataSource 
    .Read(read => read.Action("Employees", "Follow").Data("addData")))) 

function addData(data) { 
    return { id: data.id }; 
} 

컨트롤러 코드 : (컨트롤러 Follow)

public System.Web.Mvc.JsonResult Employees(int? id) 
{ 
    System.Collections.Generic.List<FollowType> List = 
     new System.Collections.Generic.List<FollowType>(); 

    if (id.HasValue == true) { 
     List = FollowTypeList.FindAll(current => current.ParentId == id); 
    } else { 
     List = FollowTypeList.FindAll(current => current.ParentId == null); 
    } 

    System.Collections.Generic.List<Kendo.Mvc.UI.TreeViewItemModel> NodeList = 
     new System.Collections.Generic.List<Kendo.Mvc.UI.TreeViewItemModel>(); 

    foreach (CommonData.Domain.FollowType item in List) 
    { 
     NodeList.Add(new Kendo.Mvc.UI.TreeViewItemModel() { 
      Id = item.Id.ToString(), 
      Text = item.Title, 
      HasChildren = FollowTypeList.Exists(c => c.Id == item.ParentId) 
     }); 
    } 

    return Json(NodeList, System.Web.Mvc.JsonRequestBehavior.AllowGet); 
} 

답변

0

나는 당신의 자바 스크립트 코드에서 데이터의 id 필드 Id을해야한다고 생각 (수 대문자에주의하십시오.) :

return { id : data.Id }; 
관련 문제