Kendoui网格,数据源和宁静的服务

时间:2012-12-19 19:19:57

标签: kendo-ui

Q1 :我正在尝试将kendoui网格绑定到与休息服务通信的数据源(使用servicestack)。一切正常,除非我调用PUT并且其余服务发送回持久的poco对象,我得到一个奇怪的javascript错误,你没有得到数据源的成功方法。

错误是

Uncaught SyntaxError: Unexpected number kendo.all.min.js:9
extend.setter kendo.all.min.js:9
o.extend._set kendo.all.min.js:9
T.extend.accept kendo.all.min.js:9
o.extend._accept kendo.all.min.js:9
(anonymous function) kendo.all.min.js:9
n jquery.min.js:2
o.fireWith jquery.min.js:2
o.fire jquery.min.js:2
g.(anonymous function).call.c.success kendo.all.min.js:9
n jquery.min.js:2
o.fireWith jquery.min.js:2
w jquery.min.js:4
d

数据源/网格配置类似于

$(document).ready(function () {
    var crudServiceBaseUrl = "/api/configuration/databaseconnections";
    $("#grid").kendoGrid({
    dataSource: {
        type: "json",
        transport: {
        read: {
            url: crudServiceBaseUrl,
            dataType: "json"
        },
        update: {
            url: function (db) {
            console.log(db);
            return crudServiceBaseUrl + "/" + db.Id;
            },
            type: "PUT",
            success: function (result) {
            console.log(result);
            }
            //dataType: "json"
        },
        destroy: {
            url: function (db) {
            return crudServiceBaseUrl + "/" + db.Id;
            },
            type: "DELETE",
            //dataType: "json"
        },
        create: {
            url: function (db) {
            return crudServiceBaseUrl + "/" + db.Id;
            },
            type: "PUT",
            //dataType: "json"
        },
        },




        schema: {
        model: {
                id: "Id",
            fields: {
            Id: { type: "string" },
            ConnectionString: { type: "string" },
            DatabaseType: { type: "string" },
            ProfileConnection: { type: "string" },
            }
        }
        },
        pageSize: 10,
        serverPaging: false,
        serverFiltering: false,
        serverSorting: false,
        model: {
        id: "Id",
        fields: {
            ConnectionString: { editable: true },
            DatabaseType: { editable: false, nullable: false, validation: { required: true } },
            ProfileConnection: { editable: false, nullable: false, validation: { required: true } },
        }
        }

    },
    height: 250,
    filterable: true,
    sortable: true,
    pageable: true,
    reorderable: true,
    resizable: true,
    toolbar: ["create"],
    columns: [{
        field: "Id",
        filterable: false,
        width: 150,
    },
        {
        field: "ConnectionString",
        title: "Connection String",
        filterable: false,
        }, {
        field: "DatabaseType",
        title: "Type",
        width: 100
        },
        {
        field: "ProfileConnection",
        title: "Profile",
        width: 100
        },
    { command: ["edit", "destroy"], title: " ", width: "210px" }
    ],
    editable: "popup"
    });
});

Q2 :任何人都有使用crud rest服务的kendoui数据源的想法或样本吗?

1 个答案:

答案 0 :(得分:1)

Q1 :正如您在评论中提到的,您发现了问题。(连接字符串中的“;”)

Q2 :但是对于第二个问题,请下载并查看此示例代码(Binding grid to a Web ApiController),它可能会帮助您或其他人在此处参考。