Hi,
I'm trying to bind the grid with a call from WebApi controller based on the project described in this blog post http://www.kendoui.com/blogs/teamblog/posts/12-11-29/the_facts_on_using_kendo_ui_with_asp_net_webapi.aspx . It's actually hitting the method in ApiContoller but the dataRequest is coming as null from and it's never hitting the ModelBinder code.
Code snippets from cshtml and controller are below:
cshtml:
@(Html.Kendo().Grid<ABC>()
.Name("grdEngagements" + Model.UniqueId)
.HtmlAttributes(new { Class = "telerikGrid" })
.AutoBind(Model.GridAutoBind)
.Columns(columns =>
{
columns.Bound(p => p.Prop1).HeaderTemplate("Header").Width(80);
columns.Bound(p => p.Prop2).Width(280);
columns.Bound(p => p.Prop3);
})
.Pageable(p => p.Messages(m => m.Display("{0} to {1} of {2}")))
.Sortable()
.Scrollable()
.Events(e => e.DataBound("gridNoDataMsgDisplay"))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.EntityId))
.Sort(s => s.Add(t => t.Prop3).Descending())
.Read(read => read
.Action("ApiControllerAction", "ApiController")
.Type(HttpVerbs.Get).Data("grdEngagementsAjaxReadAdditionalFilterData" + Model.UniqueId))
))
Controller
//see telerik sample app Grid CustomAjaxBinding for details on how this works
public JsonResult ApiControllerAction([ModelBinder(typeof(ModelBinders.DataSourceRequestModelBinder))] DataSourceRequest dataSourceRequest, string searchText, bool includeAll)
{
var request = dataSourceRequest.ToDataRequest(); // blows up at this point because dataSourceRequest is null
var sortText = GetSortString(request.Sorts);
return service.GetABC(request, searchText, sortText, includeAll)
.ToKendoJsonResult<ABCServer, ABC>();
}
I'm trying to bind the grid with a call from WebApi controller based on the project described in this blog post http://www.kendoui.com/blogs/teamblog/posts/12-11-29/the_facts_on_using_kendo_ui_with_asp_net_webapi.aspx . It's actually hitting the method in ApiContoller but the dataRequest is coming as null from and it's never hitting the ModelBinder code.
Code snippets from cshtml and controller are below:
cshtml:
@(Html.Kendo().Grid<ABC>()
.Name("grdEngagements" + Model.UniqueId)
.HtmlAttributes(new { Class = "telerikGrid" })
.AutoBind(Model.GridAutoBind)
.Columns(columns =>
{
columns.Bound(p => p.Prop1).HeaderTemplate("Header").Width(80);
columns.Bound(p => p.Prop2).Width(280);
columns.Bound(p => p.Prop3);
})
.Pageable(p => p.Messages(m => m.Display("{0} to {1} of {2}")))
.Sortable()
.Scrollable()
.Events(e => e.DataBound("gridNoDataMsgDisplay"))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.EntityId))
.Sort(s => s.Add(t => t.Prop3).Descending())
.Read(read => read
.Action("ApiControllerAction", "ApiController")
.Type(HttpVerbs.Get).Data("grdEngagementsAjaxReadAdditionalFilterData" + Model.UniqueId))
))
Controller
//see telerik sample app Grid CustomAjaxBinding for details on how this works
public JsonResult ApiControllerAction([ModelBinder(typeof(ModelBinders.DataSourceRequestModelBinder))] DataSourceRequest dataSourceRequest, string searchText, bool includeAll)
{
var request = dataSourceRequest.ToDataRequest(); // blows up at this point because dataSourceRequest is null
var sortText = GetSortString(request.Sorts);
return service.GetABC(request, searchText, sortText, includeAll)
.ToKendoJsonResult<ABCServer, ABC>();
}