KendoUi Grid不会在webform中显示数据

时间:2013-08-12 13:01:57

标签: gridview kendo-ui

服务器端代码为:

 [System.Web.Services.WebMethod]
    public static object GetDevelopers()
    {

        DqListViewModel viewMode = new DqListViewModel();

        return DQContext.Service._IDqs_IssueRepository.SelectList().Select(d => new { id = d.id, title = d.title, severityName = d.severityName, impactName = d.impactName, statusName = d.statusName }).ToList();
}

此函数返回正确的值:我可以在firebug中看到它

{“d”:[{“id”:2,“title”:“此问题的标题”,“severityName”:“高”,“impactName”:“高”,“statusName”:“有效” },{“id”:3,“title”:“此问题的标题”,“severityName”:“低”,“impactName”:“高”,“statusName”:“DeActive”},{“id”: 4,“title”:“本期标题”,“severityName”:“High”,“impactName”:“Low”,“statusName”:“Active”},{“id”:5,“title”:“此问题的标题“,”severityName“:”低“,”impactName“:”高“,”statusName“:”DeActive“},{”id“:6,”title“:”此问题的标题“,” severityName“:”High“,”impactName“:”Low“,”statusName“:”Active“},{”id“:7,”title“:”此问题的标题“,”severityName“:”低“, “impactName”:“高”,“statusName”:“DeActive”},{“id”:8,“title”:“此问题的标题”,“severityName”:“高”,“impactName”:“高” ,“statusName”:“Active”},{“id”:9,“title”:“此问题的标题”,“severityName”:“低”,“impactName”:“高”,“statusName”:“DeActive “},{”id“:10,”title“:”此问题的标题“,”severityName“:”高“,”impactName“:”低“,”statusName“:”有效“},{”id“ :11,“title”:“本期标题”,“severityName”:“低”,“我mpactName“:”高“,”statusName“:”DeActive“},{”id“:12,”title“:”此问题的标题“,”severityName“:”高“,”impactName“:”低“, “statusName”:“Active”},{“id”:13,“title”:“此问题的标题”,“severityName”:“低”,“impactName”:“高”,“statusName”:“DeActive” }]}

Kendo Grid脚本是:

<script type="text/javascript">
    $(document).ready(function () {
        var dataSource = new kendo.data.DataSource({
            type: "json",
            transport: {
                read: {
                    type: "POST",
                    url: "DQList.aspx/GetDevelopers",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json"
                },

                success: function (data) {
                    alert(data);
                },
                error: function (xhr, error) {
                    console.debug(xhr); console.debug(error);
                    alert('error');
                }
            },

            schema: {
                model: {
                    data: "d",
                    id: "id",
                    fields: {
                        issueId: { editable: false, type: "number" },
                        title: { type: "string" },
                        severityName: { type: "string" },
                        impactName: { type: "string" },
                        statusName: { type: "string" }
                    }
                }
            }

        });
        $("#tqListGrid").kendoGrid({
            dataSource: dataSource,
            groupable: true,
            sortable: true,
            autoBind: true,
            pageable: {
                refresh: true,
                pageSizes: true
            },
            columns: [
                "id",
                { field: "severityName", title: "severityName" },
                { field: "impactName", title: "impactName" },
                { field: "statusName", title: "statusName" },
                //{ command: ["edit"] },
                //{ command: ["destroy"] }
            ],
            // height: 330,
            toolbar: [{ name: "create", text: "Create New Student" }],
            editable: "popup"
        });

    });
</script>

此代码有什么问题?

1 个答案:

答案 0 :(得分:0)

dataschema定义的一部分,而不是model

应该是:

schema: {
    data : "d",
    model: {
        id    : "id",
        fields: {
            issueId     : { editable: false, type: "number" },
            title       : { type: "string" },
            severityName: { type: "string" },
            impactName  : { type: "string" },
            statusName  : { type: "string" }
        }
    }
}