This question is locked. New answers and comments are not allowed.
Hi I'm stucked with this problem.
When I try to rebind the grid after I deleted a record the grid won't be refreshed. I used the same rebinding code for the insert and the update and it works fine.
here is the code in the controller:
[AcceptVerbs(HttpVerbs.Post)]
[GridAction]
public
ActionResult Insert(UsersModel user)
{
if
(ModelState.IsValid)
{
_usersRepository.Insert(user);
}
//Rebind the grid
return
View(
new
GridModel( _usersRepository.GetList(
new
Criterion(
"Firstname"
,
"ASC"
))));
}
[AcceptVerbs(HttpVerbs.Post)]
[GridAction]
public
ActionResult Delete(UsersModel user)
{
_usersRepository.Delete(user.UsersId);
//Rebind the grid
return
View(
new
GridModel(_usersRepository.GetList(
new
Criterion(
"Firstname"
,
"ASC"
))));
}
[AcceptVerbs(HttpVerbs.Post)]
[GridAction]
public
ActionResult Update(UsersModel user)
{
if
(ModelState.IsValid)
{
_usersRepository.Update(user);
}
return
View(
new
GridModel(_usersRepository.GetList(
new
Criterion(
"Firstname"
,
"ASC"
))));
}
and this is the one in the cshtml
@(Html.Telerik().Grid(Model)
.HtmlAttributes(new { style = "width: 550px" })
.Name("Grid")
.DataKeys(k => k.Add(r => r.UsersId).RouteKey("UsersId"))
.ToolBar(commands => commands.Insert().ButtonType(GridButtonType.BareImage).ImageHtmlAttributes(new { style = "margin-left:0" }))
.Columns(columns =>
{
columns.Command(commands =>
{
commands.Edit().ButtonType(GridButtonType.BareImage);
commands.Delete().ButtonType(GridButtonType.BareImage);
}
).Width(75);
columns.Bound(u => u.FirstName).Title("First name").Width(150);
columns.Bound(u => u.LastName).Title("LastName name").Width(150);
columns.Bound(u => u.LastActivityDate).Width(130).Format("{0:dd.MM.yyyy }");
})
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("getUsers", "Users")
.Insert("Insert", "Users")
.Update("Update", "Users")
.Delete("Delete", "Users"))
.Editable(editing => editing.Mode(GridEditMode.PopUp))
.Sortable()
.Scrollable()
)
can somebody say me what I'm doing wrong?
thank you very much
Raphael