2017-12-20 23 views
0

원격 데이터 바인딩을 사용하여 범주 트리를 표시하려고합니다. 여기KendoUI for ASPMVC TreeView : 트리 대신 Json 응답 표시

public JsonResult KendoTree(Guid? id) 
    { 
     var categoriesBO = _categoryManager.GetAllCategory(). 
      Where(c=> id==null ? c.ParentId==null : c.ParentId == id). 
      Select(c=> new 
      { 
       id = c.Id, 
       Name = c.Name, 
       hasChildren = c.CategoryChilds.Any() 
      }); 
     return Json(categoriesBO, JsonRequestBehavior.AllowGet); 
    } 

@{ 
    ViewBag.Title = "KendoTree"; 
} 

    <h2>KendoTree</h2> 

    @Html.Kendo().TreeView().Name("Categories").DataSource(dataSource => dataSource 
     .Read(read => read.Action("KendoTree", "CategoryManagement") 
    )).DataTextField("Name") 

브라우저 트리 대신 JSON 결과 (배열)를 표시 cshtml 파일에게이다 여기 컨트롤러 방법이다.

나는 뭔가를 놓친가요?

답변

0

필자는 다음과 같은 뷰를 반환하는 Controller 액션이 있어야한다. 관련 뷰 내부에서 검도 Html 도우미를 호출해야한다.