Javascript 如何获取阵列数据源,剑道网格?

Javascript 如何获取阵列数据源,剑道网格?,javascript,kendo-ui,telerik,datasource,kendo-ui-grid,Javascript,Kendo Ui,Telerik,Datasource,Kendo Ui Grid,我得到了一个属性数组,我想在网格中显示所有属性 怎么做?可能吗 这是我的代码: function StartBuild(ProfileProperties) { var details = []; for (i = 0; i < ProfileProperties.length; i++) { details[i]=[{ name: ProfileProperties[i][0], email: ProfileProperties[i

我得到了一个属性数组,我想在网格中显示所有属性

怎么做?可能吗

这是我的代码:

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"
                },
            });
        });
    }
函数开始构建(ProfileProperties){
var详细信息=[];
对于(i=0;i

只有在我编写
详细信息[0]
时,它才会显示第一个属性,否则它不会显示任何内容。

看起来有几个问题

首先,传输设置不正确。pageSize、batch和schema不是传输配置的一部分……您需要将它们从传输块中取出,并将它们放在数据源块中

你想要:

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 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详细信息=[];
对于(i=0;i
而不是:

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] }];
}
var详细信息=[];
对于(i=0;i
没有直接导致问题但不正确的其他两个问题是:

  • dataSource.schema配置与实际数据完全不匹配。模式确实需要匹配实际数据的字段,否则它无法匹配配置
  • 您在网格配置中拼写“pageable”错误

  • 请添加您的html