0

我正在使用 Telerik mvc 3。

我有一个绑定到 ViewModel 的 Grid。

@(Html.Telerik().Grid<SampleProject.ViewModels.Location.RoomViewModel>()
            .Name("Grid")
            .ToolBar(cmd => cmd.Insert())
            .DataKeys(keys => keys.Add(c => c.RoomId))
            .DataBinding(dataBinding => dataBinding
                   .Ajax()
                   .Select("Selecting", "Location")
                        .Insert("Inserting", "Location")
                           .Update("Updating", "Location")
                           .Delete("Deleting", "Location" )
                       )
            .Columns(c =>
                {
                    c.Bound(o => o.RoomName);
                    c.Bound(o => o.MaxSeats);
                    c.Bound(o => o.HasScanner);
                    c.Bound(o => o.HasPrinter);
                    c.Bound(o => o.HasFlipchart);
                    c.Bound(o => o.HasBeamer);
                    c.Command(cmd =>
                        {
                            cmd.Edit();
                            cmd.Delete();
                        });
                })
          )

“插入”方法工作正常(我将 RoomViewModel 作为参数)。“选择”方法也有效,但“删除”方法不起作用。

    #region GridActions
    [GridAction]
    public ActionResult Selecting()
    {
        return View(new GridModel(this._currentLocation.Rooms));
    }

    [AcceptVerbs(HttpVerbs.Post)]
    [GridAction]
    public ActionResult Inserting(RoomViewModel rvm)
    {
        this._currentLocation.Rooms.Add(rvm);
        return View(new GridModel(this._currentLocation.Rooms));
    }

    [AcceptVerbs(HttpVerbs.Post)]
    [GridAction]
    public ActionResult Deleting(RoomViewModel rvm)
    {
        this._currentLocation.Rooms.Remove(rvm);
        return View(new GridModel(this._currentLocation.Rooms));
    }

我也试过:

        public ActionResult Deleting(int rvm) --> internal error 500 - doesnt hit the breakpoint

        public ActionResult Deleting(string rvm)

        public ActionResult Deleting(object rvm)

总是“NULL”,知道吗???

4

1 回答 1

0

实际上删除操作方法需要实体身份作为参数:

public ActionResult _DeleteAjaxEditing(int id)
于 2012-07-28T19:54:26.047 回答