Kendo UI 网格从不触发销毁方法
Posted
技术标签:
【中文标题】Kendo UI 网格从不触发销毁方法【英文标题】:KendoUI grid never fires destroy method 【发布时间】: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
动词
【参考方案1】:
这不是 Kendo 的问题,只是 HttpDelete 的问题。
问题出在 WebDAV 模块上,this link 的回答非常适合我。简而言之,只需更改您的 web.config:
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
【讨论】:
以上是关于Kendo UI 网格从不触发销毁方法的主要内容,如果未能解决你的问题,请参考以下文章
在 kendo-ui 网格中显示/隐藏列后,有啥方法可以自动调整网格列宽?
Angular 2 Grid dataBound 事件的 Kendo UI