开发者

Telerik ASP.NET MVC2 Grid Delete Function with compound key

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)
开发者_如何学Go

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");
                        })


The 2nd key returned as Id rather ItemID. there is a way to define it in the code:

       .DataKeys(dataKeys =>
            {
              dataKeys.Add(e => e.OrderID).RouteKey("OrderID");
              dataKeys.Add(e => e.ActivityID).RouteKey("ActivityID");
            })

Which give you a better chance to get what you expect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜