【问题标题】:Unable to call server side functions on update and delete functionality of Kendo UI无法在 Kendo UI 的更新和删除功能上调用服务器端功能
【发布时间】:2012-07-24 10:14:06
【问题描述】:

我在我的应用程序中使用带有 WEB API 的 MVC。我正在使用带有弹出编辑功能的 Kendo Grid。我能够获取数据并绑定网格。但是当我尝试编辑或删除一行时,问题就出现了。 parameterMap: function(options, operation) 的操作参数一直显示为 create 并且在更新和销毁的情况下会命中相同的创建传输 url。

我在这段代码中做错了什么:

dataSource = new kendo.data.DataSource({
        type: "json",
        transport: {
            read: {
                cache: false,
                url: GETUSER_API_URL,
                contentType: "application/json; charset=utf-8", 
                datatype: "json"
            },
            create: {
                cache: false,
                url: UPDATEUSER_API_URL,
                contentType: "application/json; charset=utf-8",
                type: "POST",
                datatype: "json"
            },
            update: {
                cache: false,
                url: UPDATEUSER_API_URL,
                contentType: "application/json; charset=utf-8",
                type: "POST",
                datatype: "json"
            },
            destroy: {
                url: DELETEUSER_API_URL,
                contentType: "application/json; charset=utf-8",
                type: "POST", 
                datatype: "json"
            },
            parameterMap: function (options, operation) {
                debugger;
                if (operation == "update" || operation == "create") {
                    if (options.models[0].UserProfileId == null && operation != "destroy") {
                        operation = "create";
                    }
                    else {
                        operation = "update";
                    }
                    return kendo.stringify({ models: options.models[0] });
                }
                else if (operation == "destroy") {

                    return kendo.stringify({ models: options.models[0] });
                }
            }
        },
        batch: true,
        pageSize: 10,
        schema: {
            model: {
                id: "UserProfileID",
                fields: {
                    FirstName: { validation: { required: true } },
                    LastName: { validation: { required: true } },
                    EmailId: { nullable: false, validation: { required: true } }
                }
            }
        }
    });

此外,我如何将行数据发送回 API?

【问题讨论】:

    标签: asp.net-mvc asp.net-web-api kendo-ui grid


    【解决方案1】:

    尝试使用该配置配置您的 webconfig:

    <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />
      <modules runAllManagedModulesForAllRequests="true" />
    </system.webServer>
    

    我遇到了同样的问题,但是当我添加 &lt;modules runAllManagedModulesForAllRequests="true" /&gt; webapi 工作正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-11-25
      • 2017-05-17
      • 2020-11-09
      • 2013-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多