【问题标题】:Kendo grid json post剑道网格 json 帖子
【发布时间】:2015-08-03 16:49:45
【问题描述】:

我有一个使用 Kendo 网格的 MVC 应用程序,如下所示:

var products = [{
        ProductID: 1,
        FullName: "Chai",
        IsHeadmaster: "T"
    }];

$("#teachers").kendoGrid({
    dataSource: {
        type: "json",
        transport: {
            read: function (e) {
                // on success
                e.success(products);
                // on failure
                //e.error("XHR response", "status code", "error message");
            },
            update: {
            type: "POST",
            url: "/Home/UpdateTeachers",
            dataType: "json",
            contentType: "application/json"
                        },
            parameterMap: function(data, operation) {
                if (operation === "update" || operation === "create") {
                    return JSON.stringify({product: data});
                }
                return data;
            }

        },
        batch: true,
        schema: {
            model: {
                id: "TeacherId",
                fields: {
                    TeacherId: { type: "number" },
                    FullName: { type: "string" },
                    IsHeadmaster: { type: "boolean" }
                }
            }
        }
    },
    toolbar: ["create", "save"],
    columns: [
        { field: "FullName", title: "Teacher" },
        { field: "IsHeadmaster", title: "Is a Headmaster?", width: "120px" },
        { command: ["destroy"], title: " ", width: "85px" }],
    editable: true
});

我的控制器为:

public JsonResult UpdateTeachers(string models)
{
 // do update here
}

网格加载和显示完美,但是当我尝试进行编辑和更新时出现以下错误:

第 6684 行第 17 列未处理的异常 http://localhost:5227/kendo/js/kendo.web.js

0x800a01b6 - JavaScript 运行时错误:对象不支持属性 或方法“调用”

我正在使用 JQuery 1.8.2。

任何想法/帮助将不胜感激?

【问题讨论】:

    标签: javascript jquery json asp.net-mvc kendo-grid


    【解决方案1】:

    你可以通过编辑下面的代码来试试这个

    而不是

    return JSON.stringify({product: data});
    

    使用

    return { models: kendo.stringify(data.models) };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多