2016-10-06 4 views
0

Kendo TreeList 구성 요소를 사용하고 요청시 원격 데이터를 처리하려고합니다. 이 데이터 소스가 모습입니다 같은 :검도 UI TreeListDatasource 원격 데이터 주문형 ID가 null입니다.

dsLocations = new kendo.data.TreeListDataSource({ 
    transport: { 
     read: { 
      url: baseUrl + "getsuggestedorganizationlocations?oid=" + $("#Id").val(), 
      dataType: "json" 
     }, 

     schema: { 
      model: { 
       id: "Id", 
       parentId: "ParentId", 
       fields: { 
        Id: { type: "number", nullable: false }, 
        ParentId: { field: "ParentId", nullable: true } 
       } 
      } 
     } 
    } 
}); 

이것은 TreeList 구성 요소를 구성하는 방법입니다 :

$("#suggestedLocations").kendoTreeList({ 
    dataSource: dsLocations, 
    columns: [ 
     { field: "Name", expandable: true, title: "Location", width: 250 }, 
     { field: "Selected", title: "Selected" } 
    ] 
}); 

그리고이 서버에서 오는 데이터가 루트의 모습입니다 :

[{"Id":5,"ParentId":null,"Selected":true,"hasChildren":true,"Name":"Kitchen"}] 

노드를 확장하여 하위를 검색 할 때 서버에 전달 된 쿼리 문자열의 "id"는 비어 있습니다.

Empty id

내 모델에 서버에서 오는 변경하는 경우

: ID와 parentId이 경우 낮은

[{"id":5,"parentId":null,"Selected":true,"hasChildren":true,Name":"Kitchen"}] 

, 그것은 작동합니다. 내 이해는 스키마 구성을 매핑하는 것입니다. 나는 무엇을 놓쳤는가?

검도를 사용하고 있습니다. 2016.3.914

답변

0

찾았습니다. 나는 스키마 설정을 전송 설정 안에 넣었다. 다음과 같이해야합니다.

dsLocations = new kendo.data.TreeListDataSource({ 
    transport: { 
     read: { 
      url: _organizeApp.baseUrl + "getsuggestedorganizationlocations?oid=" + $("#Id").val(), 
      dataType: "json" 
     } 

    }, 
    schema: { 
     model: { 
      id: "Id", 
      parentId: "ParentId", 
      fields: { 
       Id: { field: "Id", type: "number", nullable: false }, 
       ParentId: { field: "ParentId", nullable: true }, 

      } 
     } 
    } 
});