2017-04-04 50 views
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" 
       }, 
      }); 
     }); 
    } 

只有当我写details[0]它显示的第一属性,否则它不会显示任何东西。

+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. 你拼写为“分页”错在网格配置。