【问题标题】:KendoUI grid never fires destroy methodKendo UI 网格从不触发销毁方法
【发布时间】:2015-01-25 14:58:51
【问题描述】:

我的 kendoUI 从不触发销毁方法?我究竟做错了什么。网格正确显示数据但未能删除记录。

$("#registration-grid").kendoGrid({
                    dataSource: {
                        type: "json",
                        transport: {
                            read: {
                                url: "@Html.Raw(Url.Action("List", "Participant"))",
                                type: "POST",
                                dataType: "json"                                  
                            },
                            destroy: {
                                url: "http://localhost:53669/api/participant/",
                                type: "DELETE",
                                dataType: "json"                                   
                            }
                        },
                        schema: { data: "Data", total: "Total", model: { id: "Id" } },
                        batch: false,                          
                    },
                    pageable: { ... },
                    editable: { mode: "inline" },                      
                    columns: [
                        {  field: "Id", title: "Id",  width:50,filterable: false },
                     { command: ["destroy"], title: " ", width: "250px" }
                    ]                      

                });

Web api 控制器参与者:在 fiddler /api/participant/delete/2 作品上测试

    [HttpDelete]
    public HttpResponseMessage Delete(int id)
    {
        var participant = _participantService.Get(p => p.Id == id);
        if (participant == null)
            return Request.CreateResponse(HttpStatusCode.BadRequest);
        try
        {
            _participantService.Delete(participant);
            return Request.CreateResponse(HttpStatusCode.OK);
        }
        catch (Exception)
        {
            return Request.CreateResponse(HttpStatusCode.BadRequest);
        }

    }

点击Delete 405 Method Not Allowed时KendoGrid显示错误,请求的资源不支持http方法'DELETE'

【问题讨论】:

  • 尝试在控制器上将动词更改为 HttpPost 并在 html 中设置类型:“POST”。这里有一个例子demos.telerik.com/kendo-ui/grid/editing
  • 最好的低成本解决方案是:将httpdelete verb改为httppost动词

标签: asp.net-mvc kendo-ui telerik


【解决方案1】:

这不是 Kendo 的问题,只是 HttpDelete 的问题。

问题出在 WebDAV 模块上,this link 的回答非常适合我。简而言之,只需更改您的 web.config:

<system.webServer>
    <modules>
      <remove name="WebDAVModule" />
    </modules>
    <handlers>
      <remove name="WebDAV" /> 
    </handlers>
</system.webServer>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-02
    • 1970-01-01
    相关资源
    最近更新 更多