数据未显示在kendo UI网格中

时间:2013-06-12 15:35:43

标签: kendo-ui kendo-grid

我有以下代码

 var entries = [
                    { "value":"AAPL", "data":665.24, "shares":100 },
                    { "value":"AMZN", "data":248.27, "shares":100 },
                    { "value":"IBM", "data":194.85, "shares":100 },
                    { "value":"CSCO", "data":19.08, "shares":100 },
                    { "value":"MSFT", "data":30.82, "shares":100 },
                    { "value":"INTC", "data":24.83, "shares":100 },
                    { "value":"QCOM", "data":61.46, "shares":100 },
                    { "value":"ORCL", "data":31.65, "shares":100 },
                    { "value":"HPQ", "data":16.88, "shares":100 },
                    { "value":"CRM", "data":145.18, "shares":100 }
                ];
                var kendogridds = new kendo.data.DataSource({data:entries,
                    schema:{
                        model:{
                            fields:{
                                value:{ type:"string" },
                                data:{ type:"string" }
                            }

                        }
                    }})


                $('#myupdategrid').kendoGrid({
                    dataSource:kendogridds,
                    height: 100,
                    columns:[{field:'data',title:'Data'},
                    {field:'value',title:'Value'}],
                    dataBound: onDataBound,
                    dataBinding: onDataBinding

                })

我可以看到正在创建网格,但所有单元格都是空的。任何线索为什么?

1 个答案:

答案 0 :(得分:0)

你是对的。这个模型有些奇怪。我不认为它喜欢数据作为数据阵列中的关键。一旦我改变了,一切都开始正常。我希望这有助于人们。

这是我的代码

 var typeObject = {}
                        typeObject.name = properties
                        typeObject.value = map[properties]
                        gridArray.push(typeObject)

 var kendogridds = new kendo.data.DataSource({
                    data:gridArray,
                    schema:{
                        model:{
                            fields:{
                                name:{ type:"string" },
                                value:{ type:"string" }
                            }

                        }
                    }})


                console.log(kendogridds)
                $('#myupdategrid').kendoGrid({autoBind:false,
                    dataSource:kendogridds,
                    columns: [{
                        field: "name",// create a column bound to the "name" field
                        title: "Data" // set its title to "Name"
                    }, {
                        field: "value",// create a column bound to the "age" field
                        title: "Value" // set its title to "Age"
                    }]

                })
                kendogridds.read()