Telerik ASP.NET MVC2 Grid Delete Function with compound key.
Posted
by
Dani
on Stack Overflow
See other posts from Stack Overflow
or by Dani
Published on 2011-01-13T12:33:30Z
Indexed on
2011/01/16
13:53 UTC
Read the original article
Hit count: 183
asp.net-mvc-2
|telerik-grid
I have a grid with a compound key: OrderId, ItemID.
When I update the grid - the
public ActionResult UpdateItemGridAjax(int OrderID, string ItemID)
Gets both values from the grid.
When I delete a row I get only the first one:
public ActionResult DeleteItemGridAjax(int OrderID, string ItemID)
Why is it happens and how can I get the ItemId value of the deleted row ?
Grid Definition:
<%=
Html.Telerik().Grid<ItemsInOrderPOCO>()
.Name("ItemsInOrderGrid")
.DataKeys(dataKeys =>
{
dataKeys.Add(e => e.OrderID);
dataKeys.Add(e => e.ItemID);
})
.ToolBar(commands => commands.Insert())
.DataBinding(dataBinding =>
{
dataBinding.Ajax() //Ajax binding
.Select("SelectItemGridAjax", "Orders", new { OrderID = Model.myOrder.OrderID })
.Insert("InsertItemGridAjax", "Orders", new { OrderID = Model.myOrder.OrderID })
.Update("UpdateItemGridAjax", "Orders")
.Delete("DeleteItemGridAjax", "Orders");
})
.Columns(c =>
{
c.Bound(o => o.ItemID);
c.Bound(o => o.OrderID).Column.Visible = false;
c.Bound(o => o.ItemDescription);
c.Bound(o => o.NumOfItems);
c.Bound(o => o.CostOfItem);
c.Bound(o => o.TotalCost);
c.Bound(o => o.SupplyDate);
c.Command(commands =>
{
commands.Edit();
commands.Delete();
}).Width(180).Title("Upadte");
})
© Stack Overflow or respective owner