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

Entity with associations; grid not displaying.

1 Answer 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Liam
Top achievements
Rank 1
Liam asked on 27 Sep 2012, 08:50 AM
Hello,

I have an entity with regular properties as well as navigation properties.

The grid fails to load anything If any item in the whole DataSourceResult has any of navigation properties populated (if any entity has has any other entity associated with it).

I do not want to use any of the data from the navigation properties in the grid, I want to only use the regular properties.

Controller:
public ActionResult GetPeopleData([DataSourceRequest] DataSourceRequest request)             
{
    return Json(db.People.ToDataSourceResult(request));
}
View:
@(Html.Kendo().Grid<Models.Person>()
    .Name("PeopleGrid")
    .Columns(columns =>
    {
        columns.Bound(p => p.Id).Groupable(false).Visible(true);
        columns.Bound(p => p.LastName);
        columns.Bound(p => p.FirstName);
    })
    .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("GetPeopleData", "People"))
        )
    .Events(events => events.Change("PeopleGrid_RowSelected"))
)

If I clear all the associated tables and just have the people table populated the grid works fine.

Anyone have any ideas?

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 01 Oct 2012, 02:49 PM
Hi Liam,


To avoid circular reference exeption you should use a View Model and exclude the properties which create the circular references. We have addressed this in our Grid FAQ.

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Liam
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or