2017-04-04 11 views
0

배열의 배열을 가져 왔으며 모두 격자에 표시하고 싶습니다.어떻게 배열 데이터 소스, 검도 - 그리드를 얻을 수 있습니까?

그것을 어떻게? 가능한가? 나는 그것이 첫 번째 특성은, 그렇지 않으면 아무것도 표시되지 않습니다 보여줍니다 details[0] 쓰기 만하면

function StartBuild(ProfileProperties) { 
     var details = []; 
     for (i = 0; i < ProfileProperties.length; i++) { 
      details[i]=[{ name: ProfileProperties[i][0], email: ProfileProperties[i][1], phoneWork: ProfileProperties[i][2], Mobile: ProfileProperties[i][3], ManagerName: ProfileProperties[i][4] }]; 
     } 
      $(document).ready(function() { 
      var datasource = new kendo.data.DataSource({ 
       transport: { 
        type:"odata", 
        read: function (e) { 
         e.success(details); 
        }, 
        pageSize: 10, 
        batch: false, 
        schema: { 
         model: { 
          fields: { 
           name: { editable: false }, 
           Fname: { editable: false } 
          } 
         } 
        } 
       } 
      }); 
      $("#grid").kendoGrid({ 
       dataSource: datasource, 
       pegable: true, 
       sortable: { 
        mode: "single", 
        allowUnsort: false 
       }, 
       columns: [{ 
        field: "name", 
        title: "name", 
        filterable: { 
         cell: { 
          enabled:true 
         } 
        } 
       }, {//[Bild, nameP, email,phonework, Mobile, ManagerName] 
        field: "email", 
        title: "email" 
       }, { 
        field: "phoneWork", 
        title: "phoneWork" 
       }, { 
        field: "Mobile", 
        title: "Mobile" 
       }, { 
        field: "Manager", 
        title: "Manager" 
       }], 
       filterable: { 
        mode: "row" 
       }, 
      }); 
     }); 
    } 

:

내 코드입니다.

+0

html – Dwhitz

답변

0

몇 가지 문제가있는 것처럼 보입니다.

http://dojo.telerik.com/@Stephen/uVOjAk

첫째, 전송 설정이 올바르지 않습니다. pageSize, 배치 및 스키마가 이 아니고 전송 구성의 일부인 ... 전송 블록에서 가져와 데이터 소스 블록에 넣어야합니다.

당신이 원하는 :

var datasource = new kendo.data.DataSource({ 
    transport: { 
     type:"odata", 
     read: function (e) { 
      e.success(details); 
     }, 
     pageSize: 10, 
     batch: false, 
     schema: { 
      model: { 
       fields: { 
        name: { editable: false }, 
        Fname: { editable: false } 
       } 
      } 
     } 
    } 
}); 

둘째, 자세한 사항은 객체의 배열 할 필요가, 배열의 하지 배열 대신 (당신이 무엇을)의

var datasource = new kendo.data.DataSource({ 
    transport: { 
     type:"odata", 
     read: function (e) { 
      e.success(details); 
     } 
    }, 
    pageSize: 10, 
    batch: false, 
    schema: { 
     model: { 
      fields: { 
       name: { editable: false }, 
       Fname: { editable: false } 
      } 
     } 
    } 
}); 

객체. 대신

var details = []; 
for (i = 0; i < ProfileProperties.length; i++) { 
    details.push({ name: ProfileProperties[i][0], email: ProfileProperties[i][1], phoneWork: ProfileProperties[i][2], Mobile: ProfileProperties[i][3], ManagerName: ProfileProperties[i][4] }); 
} 

:

당신이 원하는 바로 문제가 발생하지 않습니다

var details = []; 
for (i = 0; i < ProfileProperties.length; i++) { 
    details[i]=[{ name: ProfileProperties[i][0], email: ProfileProperties[i][1], phoneWork: ProfileProperties[i][2], Mobile: ProfileProperties[i][3], ManagerName: ProfileProperties[i][4] }]; 
} 

다른 두 문제를하지만 잘못된 것은 다음과 같습니다

  1. 귀하의 dataSource.schema 구성이 실제 데이터와 전혀 일치하지 않습니다. 스키마는 실제로 실제 데이터의 필드와 일치해야합니다. 그렇지 않으면 구성을 일치시킬 수 없습니다.
  2. 그리드 구성에서 "페이징 가능"오류를 철자했습니다.