Here is my grid which is in MyPartialView:
@(Html.Telerik().Grid<MyClass>()
.Name("GridMyClass")
.ToolBar(commands => commands.Insert().ButtonType(GridButtonType.BareImage))
.DataKeys(keys => keys.Add(a => a.Id))
.ClientEvents(events => events.OnError("Grid_onError"))
.Columns(columns =>
{
columns.Bound(p => p.Name).Width(110);
columns.Bound(p => p.Timestamp).Width(110).Format("{0:MM/dd/yyyy}");
columns.Command(commands =>
{
commands.Edit().ButtonType(GridButtonType.BareImage);
commands.Delete().ButtonType(GridButtonType.BareImage);
}).Width(180).Title("Edit");
})
.DataBinding(dataBinding =>
{
dataBinding.Ajax()
.Select("Ge", "MyClass")
.Update("Edit", "MyClass")
.Delete("Delete", "MyClass")
.Insert("Insert", "MyClass");
})
.Pageable()
.Sortable()
//.Scrollable()
//.Groupable()
//.Filterable()
//.Editable(editing => editing.Mode(GridEditMode.InLine))
)
Here is one of the controller methods (the others are similar):
public ActionResult Delete()
{
//delete
//get the model
List<MyClassTemplate> ct = new List<MyClassTemplate>();
//fill ct
return PartialView("MyPartialView", new GridModel<MyClassTemplate> { Data = ct });
}
And another controller method:
public ActionResult MyPartialView()
{
List<MyClassTemplate> ct = new List<MyClassTemplate>();
//fill ct
return PartialView(ct);//new GridModel(ct)
}
When I edit a row in the grid and click on the image to save the edited row, I step with breakpoints throught the controller methods. Everything is fine. ct has ok value. However, I get alert “Error! The requested URL did not return Json.”. Which url did not return json? How to resolve this?
The error was pretty self-explanatory. Instead of a partial view, I should have returned json.