我在kendo上添加了删除按钮,现在我正在尝试删除并收到以下错误。
delete命令需要删除数据绑定设置。 请在DataBinding配置中指定删除操作或URL
<div class="form-group">
@(Html.Kendo().Grid(dataList)
.Name("MyGrid")
.Columns(column =>
{
column.Bound(c => c.PartId).Width("70px").HeaderHtmlAttributes(new { style = "vertical-align:top !important;" }).FooterHtmlAttributes(new { style = "display:none;" });
column.Bound(c => c.GMarkPartNumber)
.Title("GM Part No").Width("90px").FooterHtmlAttributes(new { style = "display:none;" });
column.Bound(c => c.Description).FooterHtmlAttributes(new { style = "display:none;" });
column.Group(grp => grp
.Title("Price")
.Columns(info =>
{
info.Bound(x => x.Price).FooterHtmlAttributes(new { style = "display:none;" });
info.Bound(x => x.Fitting).FooterHtmlAttributes(new { style = "display:none;" });
info.Bound(x => x.Extras).FooterHtmlAttributes(new { style = "display:none;" });
info.Bound(x => x.VAT).FooterHtmlAttributes(new { style = "display:none;" });
info.Bound(x => x.TotalInc).FooterTemplate("<div class=\"row\"><div class=\"col-md-4 pull-right\"><div class=\"pull-right\">" +
"<table><tr><td class=\"formatFooter\">Total Exclusive:</td><td class=\"formatFooter\">R" + data.totalExclusive + "</td></tr>"
+ "<tr><td class=\"formatFooter\">Total VAT:</td><td class=\"formatFooter\">R" + data.totalVat + "</td></tr>"
+ "<tr><td class=\"formatFooter\">Total Inclusive:</td><td class=\"formatFooter\">R" + data.totalInclusive + "</td></tr></table></div></div></div>")
.FooterHtmlAttributes(new { colspan = 8 });
}));
column.Command(x => x.Destroy());
})
.Groupable()
.Scrollable()
.Sortable()
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
.DataSource(dataSource => dataSource.Server()
));
</div>
答案 0 :(得分:0)
在您的数据源配置中,您需要添加这样的语句(如果使用ajax):
.DataSource(ds =>{
ds.Ajax()
.Create(create => create.Action(....))
.Read(read => read.Action(....))
.Update(update => update.Action(....))
.Delete(delete =>
delete.Action("action","controller","{area if required}"));
}
);
如果您想手动处理删除机制,则需要添加自定义删除按钮,然后以您需要的方式对其进行配置。
如果您需要扩展,请告诉我,如果需要,我会添加更多详细信息。
修改强>
如果您正在使用代码示例中的datasource.Server()实现,只需添加方法.Destroy(&#34; action&#34;,&#34; controller&#34;,&#34; route values& #34)
e.g。改变
.DataSource(dataSource => dataSource.Server())
到
.DataSource(data => data.Server().Destroy("action", "controller", new {area ="route options if required"}))
这应该允许删除按钮工作。