0

这是我创建剑道网格的方法

var grid = $("#grid").kendoGrid({
    autobind:true,
    dataSource: {
        transport: {
            read: {
                url: "getFacetTree?action=datagrid",
                dataType: "json"
            }
        },

        schema: {
            model: {
                fields: {
                    Details: { type: "number" },
                    Date: { type: "string" },
                    AuthorSender: { type: "string" },
                    Recipients: { type: "string" },
                    SubjectFilename: { type: "string" },
                    Action: { type: "string" }
                }
            }
        },
        pageSize: 10,
        serverPaging: true,
        serverFiltering: true,
        serverSorting: true
    },
    height: 250,
    sortable: {
        mode: "multiple",
        allowUnsort: true
    },
    filterable: {
        extra: false,
        operators: {
            string: {
                startswith: "Starts with",
                eq: "Is equal to",
                neq: "Is not equal to"
            }
        }
    },
    columnMenu: true,
    resizable: true,
    pageable: {
        input: true,
        numeric: false,
        pageSizes: true,
        messages: {
            display: "{2} - Documents found, displaying {0} to {1}"
        }
    },
    editable: true,
    columns: [
        {
            field: "",
        title: "<input id='headerCheckbox' onclick='selectRows(this)' type='checkbox' name='selected' />",
        width: 21,
        template: "<input class='rowCheckbox' type='checkbox' name='selected' />"
        },
        {
            field: "Details",
            title: "Details",
            width: 50
        },
        {
            field: "Date",
            title: "Date",
            width: 100
        },
        {
            field: "AuthorSender",
            title: "Author/Sender",
            width: 150
        },
        {
            field: "Recipients",
            title: "Recipients",
            width: 150
            /*filterable: false*/
        },
        {
            field: "SubjectFilename",
            title: "Subject/Filename",
            width: 150
        },
        {
            field: "Action",
            title: "Action",
            width: 60
        }
    ] 
});

我从数据源得到的响应是 -

[{ Details : 1,  Date : "12-06-2000",    AuthorSender : "sd",    Recipients : "we",    SubjectFilename : "abc abc.url",    Action : "view"},{ Details : 1,  Date : "12-06-2000",    AuthorSender : "sd",    Recipients : "we",    SubjectFilename : "abc abc.url",    Action : "view"}]

但响应未在网格中更新。有什么我做错了吗?

Firebug(net tab) 中的分析表明它有 5 个选项卡——Params、Headers、Response、Cache、XML、Cookies。
在 XML 选项卡下,我得到了这个(也许这是错误的地方) -

XML Parsing Error: syntax error Location: moz-nullprincipal:{c48e084c-70a2-4462-8411-0a950e5325d9} Line Number 1, Column 1:

[{ Details : 1,  Date : "12-06-2000",    AuthorSender : "sd",    Recipients : "w...
4

1 回答 1

0

有两个错误:
1. json 响应中的key字段应该有引号。2.在模式下,我必须将响应
解析如下stringjson

schema: {
    model: {
        fields: {
            Details: { type: "String" },
            ...
            Action: { type: "String" }
        }
    },
    parse: function(response) {
        return $.parseJSON(response);
    }
},
于 2013-07-19T06:51:36.917 回答