Kendo UI JSONP网格不起作用

时间:2012-12-07 17:42:25

标签: grid jsonp datasource kendo-ui

我在下面有这个页面,其中data:piece看起来就像来自服务器的JSONP,但它没有显示任何具有此概念证明的数据。

稍后我希望用

替换数据:部分
transport : {
read : "dwr/jsonp/DemoProxy/read/arg0",
dataType : "jsonp"
},

但是我们首先让下面的页面工作。

<html><body>
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
<script src="http://cdn.kendostatic.com/2012.2.710/js/kendo.all.min.js"></script>
<link href="styles/kendo.common.min.css" rel="stylesheet" />
<link href="styles/kendo.default.min.css" rel="stylesheet" />
    <div id="grid0"></div>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#grid0').kendoGrid({
                dataSource : {
                    data : [ {
                        "reply" : [ {
                            "location" : "dfg", "multi" : "dfg", "name" : "dfg"
                        }, {
                            "location" : "dfg", "multi" : "dfg", "name" : "dfg"
                        } ]
                    } ],
                    schema : {
                        data : "reply",
                        model : {
                            fields : {
                                location : {
                                    type : "string"
                                },
                                multi : {
                                    type : "string"
                                },
                                name : {
                                    type : "string"
                                }
                            }
                        }
                    },
                },
                columns : [ {
                    field : "location", title : "Location"
                }, {
                    field : "multi", title : "Multi"
                }, {
                    field : "name", title : "Name"
                } ]
            });
        })
    </script>
</body></html>

1 个答案:

答案 0 :(得分:1)

尝试将data中的dataSource定义为:

data  :{
    "reply":[
        { "location":"dfg", "multi":"dfg", "name":"dfg" },
        { "location":"dfg", "multi":"dfg", "name":"dfg" }
    ]
},

由于在schema中您说数据位于replydataobject而不是arrayarray实际上是reply