0

我有以下代码

 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

                })

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

4

1 回答 1

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()
于 2013-06-12T18:06:49.537 回答