serverbinding in Telerik grid in MVC
I have bound the grid using server bing and the grid update method is working, but the delete method is not. I would be grateful for any suggestions as to what might be the problem.
View
<%=Html.Telerik().Grid(Model).Name("Grid").DataKeys(keys => keys.Add(m => m.ResExpID))
.Columns(columns=>
{
columns.Bound(m => m.ResExpID).Width(100);
columns.Bound(m => m.Company).Width(100);
//columns.Bound("Title").Width(100);
columns.Bound(m=>m.Title).Width(200);
columns.Command(commands =>
{
commands.Edit().ButtonType(GridButtonType.Text);
commands.Delete().ButtonType(GridButtonType.Text);
}).Width(200).Title("Command");
// columns.Bound(<asp>).Width(200);
})
.ClientEvents(events => events.OnRowSelect("onRowSelected"))
.DataBinding(dataBinding =>
{
dataBinding.Server()
.Select("WorkExperience","Editresume")
.Update("_SaveAjaxEditing", "Editresume")
.Delete("_Deleteexper开发者_如何学运维ience","Editresume");
})
.Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
.Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
.Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
.Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
.Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
.Footer((bool)ViewData["showFooter"])
.Editable(editing=>editing.Mode(GridEditMode.PopUp))
// .Editable(editing => editing.Enabled((bool)ViewData["mode"]))
.RowAction(row => row.Selected = row.DataItem.ResExpID.Equals(ViewData["id"]))
%>
Controller
public ActionResult WorkExperience()
{
int resumeid = Convert.ToInt32(Session["resumeid"].ToString());
int uid = Convert.ToInt32(HttpContext.User.Identity.Name);
var re = (from j in db.Resumes
join res in db.Res_Exp on j.ResumeID equals res.Resume.ResumeID
where j.ResumeID == resumeid && j.User.UserID==uid
select res
).AsEnumerable();
ViewData["ajax"] = true;
ViewData["scrolling"] = true;
ViewData["paging"] = true;
ViewData["filtering"] = true;
ViewData["grouping"] = true;
ViewData["sorting"] = true;
ViewData["showFooter"] = true;
ViewData["mode"] = false;
if (Request.QueryString["Grid-mode"] != null)
{
ViewData["mode"] = true;
}
return View(re);
}
[HttpPost]
public ActionResult _Deleteexperience(int resexpid,FormCollection f)
{
var user = (from results in db.Res_Exp
where results.ResExpID == resexpid select results).Single();
Res_Exp exp = (Res_Exp)user;
db.Res_Exp.DeleteObject(exp);
db.SaveChanges();
return RedirectToAction("WorkExperience");
}
精彩评论