0
在下面的网格中,我已经实现了Destroy方法来删除记录,但问题是当在服务器端删除期间发生错误时,剑道网格仍然从网格中删除记录。当我刷新页面记录再次出现按预期。如何防止Kendo网格在发生服务器端错误时删除记录并向用户显示错误消息?Kendo网格破坏命令不刷新网格
@(Html.Kendo().Grid((IEnumerable<RealEstateApp.Models.propertyOwenerModel>)Model)
.Name("grid")
.Columns(columns =>
{
columns.Bound(o => o.id).Visible(false);
columns.Bound(o => o.name).Width("150px");
columns.Bound(o => o.email).Width("100px");
columns.Bound(o => o.address).Width("200px");
columns.Bound(o => o.telephone).Width("100px");
columns.Bound(o => o.mobile).Width("100px");
columns.Template(o => Html.ActionLink("Edit", "Edit", new { o.id })).ClientTemplate("<a class='k-button k-button-icontext' href=\"" + Url.Action("Edit", "propertyOwner") + "/#= id#\"><span class='k-icon k-edit'></span>Edit</a>").Width(80).Title("Edit");
if (Roles.IsUserInRole(User.Identity.Name, "admin"))
{
columns.Command(commands =>
{
commands.Destroy(); // The "destroy" command removes data items
}).Title("Delete").Width(90);
}
//columns.Template(o => Html.ActionLink("Delete", "Delete", new { o.id })).ClientTemplate("<a class='blue' href=\"" + Url.Action("Details", "propertyOwner") + "/#= id#\"><i class='icon-zoom-in bigger-130'>Delete</i></a>").Width(65).Title("Details");
})
.ToolBar(toolbar =>
{
toolbar.Template(@<text>
<a class="k-button" href="/propertyOwner/Create"><span class="k-icon k-si-plus"></span></a>
</text>);
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.Groupable()
.HtmlAttributes(new { style = "height:900px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("AjaxGrid", "propertyOwner"))
.Destroy(destroy => destroy.Action("Destroy", "propertyOwner"))
.Model(model =>
{
model.Id(m=>m.id); // Specify the property which is the unique identifier of the model
model.Field(m => m.id).Editable(false); // Make the ProductID property not editable
})
)
)
现在我可以显示一个错误,但仍然记录从网格中删除,它不是清爽 – chamara
对于没有得到它删除,你应该定义一个'返回'errors'功能true',当没有'error'时,你的函数应该返回'false'。看到我的**编辑**的问题。 – OnaBai