我有一个剑道网格,每行都有一个删除图标。现在,每当我向其添加内容时,网格都会添加和更新数据。它删除行就好了。但是,在我删除网格中的最后一行之后,它随后在每次页面加载时开始调用destroy函数。因此,它不允许任何数据存储在网格中。这是代码,请帮助我。
@(Html.Kendo().Grid<ATMS.Data.DataAccess.DataEntities.Address>()
.Name("gvPriorAddressList")
.Columns(columns =>
{
columns.Template(@<text></text>).Width(30)
.ClientTemplate(@"<a class='k-button-icontext k-grid-delete' href='\#'><img alt='delete' src='" + Url.Content("~/Images/Layout/delete_icon.gif") + "'/></a>");
columns.Bound(p => p.Address1).Width(170);
columns.Bound(p => p.Address2).Width(170);
columns.Bound(p => p.City).Width(150);
columns.Bound(p => p.State).Width(120);
columns.Bound(p => p.Zip).Title("Zip Code").Width(120);
columns.Bound(p => p.AddressLinkID).Hidden(true);
})
.Navigatable()
.Sortable()
.Scrollable(s => s.Height("auto"))
.Editable(editable =>
{
editable.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom);
})
.Events(e => e.Edit("onAddressGridEdit"))
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.Model(model =>
{
model.Id(p => p.AddressId);
model.Field(p => p.LeadId).DefaultValue(Model);
model.Field(p => p.Address1);
model.Field(p => p.Address2);
model.Field(p => p.City);
model.Field(p => p.State);
model.Field(p => p.Zip);
})
.ServerOperation(false)
.Read(read => read.Action("GetAddress", "HomeLead", new { LeadId = Model }))
.Create(create => create.Action("AddUpdateAddress", "HomeLead", new { LeadId = Model }))
.Update(update => update.Action("AddUpdateAddress", "Homelead", new { LeadId = Model }))
.Destroy(destroy => destroy.Action("DeleteAddress", "Homelead", new { LeadId = Model }))
)
)