sicottec
sicottec

Reputation: 3

Migrating Telerik MVC Grid to Kendo UI

I am migrating an AJAX Data-bound Telerik grid to the a Kendo UI grid.

With Telerik the controller method was returning a PartialViewResult (using in-house framework function call), but with the new Kendo UI grid, I am only able to make it work by returning a JsonResult. If I return a PartialViewResult, the grid renders empty.

Question: Is it possible to return a PartialViewResult with a Kendo UI grid?

Telerik code:

[GridAction]
public PartialViewResult SelectProducts()
{
    return DoChildReadingAction(() => 
        _service.GetAllProducts().ToProductListItemViewModels(), "_ChildError");
}

Kendo UI code:

public JsonResult SelectProducts([DataSourceRequest]DataSourceRequest request)
{
    return Json(_service.GetAllProducts().ToProductListItemViewModels()
                        .ToDataSourceResult(request));
}

Upvotes: 0

Views: 1874

Answers (1)

Atanas Korchev
Atanas Korchev

Reputation: 30671

The Kendo UI Grid for ASP.NET MVC works only with JSON result. It will not work with a PartialResult. More info can be found in the AJAX binding help topic.

You just need to convert your code:

public JsonResult SelectProducts([DataSourceRequest]DataSourceRequest request)
{
    return Json(_service.GetAllProducts().ToProductListItemViewModels()
                        .ToDataSourceResult(request));
}

Also make sure you have included kendo.aspnetmvc.min.js to your page. Otherwise you would see DenyGet errors. Check the troubleshooting help topic for further details.

Upvotes: 2

Related Questions