I have a grid where I want to be able to delete rows without having to return a new result set from the controller action.
This in in my view:
@(Html.Telerik().Grid<InterestTopicViewModel>()
.Name("Grid")
.DataKeys(keys => keys.Add(x => x.Id))
.ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image).ImageHtmlAttributes(new {style="margin-left:0"}))
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("Select", "InterestTopic")
.Insert("Insert", "InterestTopic")
.Update("Update", "InterestTopic")
.Delete("Delete", "InterestTopic"))
.Columns(columns =>
{
columns.Bound(x => x.Name);
columns.Command(commands =>
{
commands.Edit().ButtonType(GridButtonType.Image);
commands.Delete().ButtonType(GridButtonType.Image);
}).Title("Actions");
})
.Editable(editing => editing.Mode(GridEditMode.InLine))
)
And here is in my controller:
[AcceptVerbs(HttpVerbs.Post)]
[GridAction]
public ActionResult Delete(int id)
{
InterestTopicViewModel interestTopicViewModel = this.InterestTopicPresenter.GetInterestTopic(id);
if (this.InterestTopicPresenter.DeleteInterestTopic(id))
base.LogUserAction(UserActionLoggingType.DeleteInterest, interestTopicViewModel.Name);
return this.View(new GridModel(this.InterestTopicPresenter.GetList()));
}
As you can see, in my controller, I must return at the end of the function the entire list in a GridModel object. If I don't do that, the view will not be refreshes.
Is it possible just delete the record with the help of the controller and let Telerik deleting the div of the corresponding row in javascript?
Thank you.