2017-10-06 4 views
0

kendo TreeView 컨트롤에서 작업 중이며 그리드에 트리 구조를 표시하려고합니다. 컨트롤러 메소드에서 json 데이터를 가져오고 있지만 컨트롤에 항상 "No records to display"라는 오류 메시지가 표시됩니다. 내 실수를 식별하는 데 도움을 줄 수 있습니까?Kendo Tree View에서 컨트롤러에서 json 결과를 가져 오는 데 대한 레코드가 표시되지 않습니다.

아래 자바 코드입니다.

<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.913/styles/kendo.common-material.min.css" /> 
 
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.913/styles/kendo.material.min.css" /> 
 
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2017.3.913/styles/kendo.material.mobile.min.css" /> 
 

 
<script src="https://kendo.cdn.telerik.com/2017.3.913/js/jquery.min.js"></script> 
 
<script src="https://kendo.cdn.telerik.com/2017.3.913/js/kendo.all.min.js"></script> 
 
<script type="text/javascript"> 
 

 
    $(document).ready(function() { 
 
     var modelId = $("#hdnModelId").val(); 
 
     var dataSource = new kendo.data.TreeListDataSource({ 
 
      transport: { 
 
       read: { 
 
        url: "/EntityData/GetEntities", 
 
        dataType: "json", 
 
        data: { modelId: modelId } 
 
       } 
 
      }, 
 
      schema: { 
 
       model: { 
 
        id: "EntityId", 
 
        parentId: "ParentEntityId", 
 
        fields: 
 
         { 
 
          Name: { field: "Name", type: "string" }, 
 
          EntityId: { type: "number", editable: false, nullable: false }, 
 
          ParentEntityId: { field: "ParentEntityId", nullable: true} 
 
         }, 
 
       } 
 
      } 
 
     }); 
 
     
 
     $("#treelist").kendoTreeList({ 
 
      dataSource: dataSource, 
 
      columns: [{ field: "Name" }] 
 
     });  
 
    }); 
 

 
    
 
</script>
.

다음은 나의 행동 방법입니다.

[HttpGet] 
    public ActionResult GetEntities(int modelId) 
    {    
     var entities = metaDataService.GetEntitiesByModelId(modelId).ToList(); 
     return Json(new { Data = entities }, JsonRequestBehavior.AllowGet); 
    } 

다음은 내 작업 방법에서 무엇입니까 JSON 데이터입니다.

{"Data":[{"EntityId":1,"ApplicationId":2,"Name":"Car","Description":"This entity describes a car.!","IsPublished":true,"IsDeleted":false,"ParentEntityId":null,"HasChildren":false},{"EntityId":20,"ApplicationId":2,"Name":"Test 567","Description":"Test 567!","IsPublished":true,"IsDeleted":false,"ParentEntityId":null,"HasChildren":false},{"EntityId":21,"ApplicationId":2,"Name":"Test Tst Entity","Description":"Test Tst Entity1234","IsPublished":true,"IsDeleted":false,"ParentEntityId":1,"HasChildren":true},{"EntityId":23,"ApplicationId":2,"Name":"Test New Entity","Description":"Test New Entity","IsPublished":true,"IsDeleted":false,"ParentEntityId":null,"HasChildren":false},{"EntityId":46,"ApplicationId":2,"Name":"Kendo Entity Test","Description":"Kendo Entity Test","IsPublished":true,"IsDeleted":false,"ParentEntityId":null,"HasChildren":false},{"EntityId":63,"ApplicationId":2,"Name":"Test new Entity","Description":"Test New Entity","IsPublished":true,"IsDeleted":false,"ParentEntityId":20,"HasChildren":true}]} 

어떤 도움은 매우

답변

0

을 시도해보십시오 사전에

감사합니다 감사합니다 addind 스키마에이 : 당신은이

schema: { 
    data: "Data" 

는 데이터 소스에게 당신의 JSON 배열되는 특성 입니다.

관련 문제