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 タブ) での分析は、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

2 つの間違いがありました:
1. json 応答のキーフィールドには引用符が必要です。
2.スキーマの下で、以下のようにstring応答を解析する必要がありましたjson

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