Kendo UI网格不与web api控制器返回的json数据绑定

时间:2013-07-26 23:20:58

标签: jquery asp.net asp.net-web-api

我正在尝试使用创建的API建模器绑定Kendo UI网格。我检查了Web API建模器,它以json格式返回数据,但是当我创建html页面以在Kendo UI网格中显示数据时,只显示网格而没有items.Here是我的html代码。有人请指出哪里出错了。提前致谢。我现在陷入这3天了。                                                        

</head>
<body>
            <div id="example" class="k-content">
            <div id="grid"></div>

            <script type="text/javascript">
                $(document).ready(function () {
 var crudServiceBaseUrl = "Customer/Get";
                    //alert(crudServiceBaseUrl);
                    dataSource = new kendo.data.DataSource({
                        transport: {
                            read: {
                                url: "Customer/Get",
                                dataType: "jsonp"
                            }
                        },
                        batch: true,
                        pageSize: 20,
                        schema: {
                            model: {
                                id: "customerID",
                                fields: {
                                    customerID: { editable: false, nullable: true },
                                    customerName: { validation: { required: true} }
                                }
                            }
                        }
                    });
                    var test = dataSource.data.length;
                    //i tried debugging but data length is 1
                        $("#grid").kendoGrid({
                            dataSource: dataSource,
                            pageable: true,
                            height: 430,
                            toolbar: ["create"],
                            columns: [
                                { field: "customerID", title: "ID", width: "200px" },
                                { field: "customerName", title: "Name", width: "200px" },
                                { command: ["edit", "destroy"], title: "&nbsp;", width: "172px"}],
                            editable: "inline"

                    });
                });
            </script>
        </div>


</body>
</html>

0 个答案:

没有答案