与Kendo Widgets的数据绑定问题

时间:2013-06-17 02:47:10

标签: kendo-ui kendo-grid

我正在使用Kendo UI Library。

尝试将数据绑定到Grid。但网格没有填充数据。

我也引用了必需的js库和样式。

<head>
    Referred necessary Styles and Scripts are in order
    <script src="scripts/jquery.min.js" type="text/javascript"></script>
    <script src="scripts/kendo.web.min.js" type="text/javascript"></script>
</head>
<body>
<div id="courses"></div>
<script type="text/javascript">
    $(document).ready(function () {
        var Courses = [
            {Name: "Theory of computation", Credit: 10},
            {Name: "Probability and Statistics", Credit: 20},
            {Name: "Discrete Maths", Credit: 10},
            {Name: "Modern Physics", Credit: 25},
            {Name: "Management Information System", Credit: 15 },
            {Name: "Game Theory", Credit: 5 }
        ];

        var courseDataSource = new kendo.data.DataSource({datasource: Courses, PageSize: 5});
        courseDataSource.read();
        $("#courses").kendoGrid({
            dataSource: courseDataSource,
            columns   : [
                { field: "Name", title: "Course Name"} ,
                { field: "Credit", title: "Credits" }
            ],
            scrollable: false,
            pageable  : true
        });
    });
</script>
</body>

请你帮我修理代码。

1 个答案:

答案 0 :(得分:1)

请将数据源更改为数据,将 PageSize 更改为 pageSize

 var courseDataSource = 
new kendo.data.DataSource({datasource: Courses, PageSize: 5});

正确的实施是

var courseDataSource = 
    new kendo.data.DataSource({data: Courses, pageSize: 5});

感谢。