This example shows the cell editting mode combined with batch updates. To enter edit mode just click a cell.
To enable cell editing with batch updatesyou need to do the following:
GridEditMode.InCell:
<%= Html.Telerik().Grid<EditableProduct>()
.Name("Grid")
.Editable(editing => editing.Mode(GridEditMode.InCell))
%>
<%= Html.Telerik().Grid<EditableProduct>()
.Name("Grid")
.ToolBar(commands => {
commands.Insert();
commands.SubmitChanges();
})
.Editable(editing => editing.Mode(GridEditMode.InCell))
%>
<%= Html.Telerik().Grid<EditableProduct>()
.Name("Grid")
.DataKeys(keys =>
{
keys.Add(p => p.ProductID);
})
.ToolBar(commands => {
commands.Insert();
commands.SubmitChanges();
})
.DataBinding(dataBinding =>
dataBinding.Ajax()
.Select("_SelectBatchEditing", "Grid")
.Update("_SaveBatchEditing", "Grid")
)
.Editable(editing => editing.Mode(GridEditMode.InCell))
%>
public ActionResult _SaveBatchEditing([Bind(Prefix = "inserted")]IEnumerable<EditableProduct> insertedProducts,
[Bind(Prefix = "updated")]IEnumerable<EditableProduct> updatedProducts,
[Bind(Prefix = "deleted")]IEnumerable<EditableProduct> deletedProducts)
{
if (insertedProducts != null)
{
foreach (var product in insertedProducts)
{
// perform insert
}
}
if (updatedProducts != null)
{
foreach (var product in updatedProducts)
{
//perform update
}
}
if (deletedProducts != null)
{
foreach (var product in deletedProducts)
{
//perform update
}
}
return View(new GridModel(SessionProductRepository.All()));
}