This is a migrated thread and some comments may be shown as answers.

Navigation Property for Kendo Grid

1 Answer 291 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rao
Top achievements
Rank 1
Rao asked on 05 Aug 2013, 03:05 PM
Do we have any navigation property for Kendo grid Datasource?

Eg:  
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.ProductID).Groupable(false);
columns.Bound(p => p.ProductName);
columns.Bound(p => p.UnitPrice);
columns.Bound(p => p.UnitsInStock);
})
.Groupable()
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Data", "API"))
)
)

From the API service, we are getting the actual data enclosed in some other object.

Our entity structure is like

Data [Class]
  1. Error Message [Property]
  2. Employees[Property]
  3. Status [Property]

I want to set grid's data source as the Employees(property) . 

Please help.

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 07 Aug 2013, 08:24 AM
Hello Rao,

 This isn't supported out of the box by the Kendo Grid for ASP.NET MVC. When configured for ajax binding the action method should return a DataSourceResult instance as JSON. More info is available in the ajax binding help topic.

 There are two ways to overcome this:

  1. Use the JavaScript version of the Kendo UI grid and configure it's data source to expect results from the "Employees" field of the response. This is done via the schema.data data source option.
  2. In the action method which returns the grid data ("Data", "API") return the Employees:
    public ActionResult Data([DataSourceRequest] DataSourceRequest request)
    {
               var result = GetResult();
               return Json(result.Employees.ToDataSourceResult(request));
    }
Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Rao
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or