Hi
I am using a customized response for the grid which contains the default "data" JSON in a property, such as:
{
"success": true,
"result": {
"data": [
{
"srtOrder": 60,
"id": 1
},
{
"srtOrder": 70,
"id": 1
},
{
"srtOrder": 30,
"id": 5
}
],
"total": 96,
"aggregateResults": null,
"errors": null
},
"error": null,
"unAuthorizedRequest": false
}
So the grid should use the data from the "result" property.
How can I define this using the MVC version of the grid?
My model which is attached to the grid matches the "data" property.
4 Answers, 1 is accepted
Hello Thomas,
This can be achieve by using custom data source in MVC wrappers. Example configuration:
.DataSource(dataSource =>
dataSource.Custom()
.Transport(tr => tr.Read("Customers_Read", "Grid"))
.Type("aspnetmvc-ajax")
.Schema(sc => sc.Data("result.data").Total("total"))
)
Regards,
Nikolay Rusev
Telerik

Hi Nikolay
Thanks for clarifying the Custom attribute. I have now tried the following:
@(Html.Kendo().Grid<DP.Application.Dto.MyModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.Id);
columns.Command(command => { command.Edit(); command.Destroy();}).Width(220);
})
.Scrollable(s => s.Height("auto"))
.DataSource(dataSource => dataSource
.Custom()
.Type("aspnetmvc-ajax")
.Schema(sc => sc.Data("result.data").Total("total")
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.Id).Editable(false);
})
)
.Transport(tr => tr.Read("x_KendoRead", "ControllerName"))
)
);
However the grid renders empty. When I inspect the request using Fiddler, I do see the data in the format defined in my first post. Is there something else that must be configured?
Best Regards
Thomas
Hello Thomas,
You might be missing the kendo.aspnetmvc.min.js script which is required for the aspnetmvc-ajax transport.
You can find an example attached to this post.
Regards,Nikolay Rusev
Telerik

Hi Nikolay
Thanks for example, which let me in the right direction to find the issue. It seemed like my custom response was using camelCase notation, but my model did not. Changing it solved the problem.