0

服务器端代码是:

 [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();
}

这个函数返回正确的值:我可以在萤火虫中看到它

{"d":[{"id":2,"title":"本期标题","severityName":"High","impactName":"High","statusName":"Active"},{ "id":3,"title":"本期标题","severityName":"Low","impactName":"High","statusName":"DeActive"},{"id":4," title":"这个问题的标题","severityName":"High","impactName":"Low","statusName":"Active"},{"id":5,"title":"这个标题issue","severityName":"Low","impactName":"High","statusName":"DeActive"},{"id":6,"title":"这个问题的标题","severityName":"High","impactName":"Low","statusName":"Active"},{"id":7,"title":"本期标题","severityName":"Low" ,"impactName":"High","statusName":"DeActive"},{"id":8,"title":"这个问题的标题","severityName":"High","impactName":"High ","statusName":"Active"},{"id":9,"title":"这个问题的标题","severityName":"Low","impactName":"High","statusName":" DeActive"},{"id":10,"title":"本期标题","severityName":"High","impactName":"Low","statusName":"Active"},{"id":11,"title":"这个问题的标题","severityName":"Low","impactName":"High","statusName":"DeActive" },{"id":12,"title":"本期标题","severityName":"High","impactName":"Low","statusName":"Active"},{"id": 13,"title":"本期标题","severityName":"Low","impactName":"High","statusName":"DeActive"}]}{"id":12,"title":"本期标题","severityName":"High","impactName":"Low","statusName":"Active"},{"id":13, "title":"这个问题的标题","severityName":"Low","impactName":"High","statusName":"DeActive"}]}{"id":12,"title":"本期标题","severityName":"High","impactName":"Low","statusName":"Active"},{"id":13, "title":"这个问题的标题","severityName":"Low","impactName":"High","statusName":"DeActive"}]}

剑道网格脚本是:

<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>

这段代码有什么问题?

4

1 回答 1

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" }
        }
    }
}
于 2013-08-12T13:30:46.560 回答