Reputation: 4445
Posted 3 hours ago (permalink)
I am getting the following error when binding my Model to a Kendo Grid.
A circular reference was detected while serializing an object of type [my type]
What is strange is that the type of the object that is causing the circular reference is not the same as the type of object of the Model for this page... ie:
@model IEnumerable<Models.Type>
Is not the same type that is causing this error. What could be the problem?
Here is the code that is generating this exception:
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.Name).Groupable(false);
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
)
)
Upvotes: 1
Views: 5405
Reputation: 30671
A known exception. Check here: https://docs.telerik.com/aspnet-mvc/helpers/grid/troubleshoot/known-exceptions#circular-reference-detected-while-serializing-an-object-of-type
Upvotes: 3
Reputation: 1
You want to select the only properties you need into an anonymous type, or to a class with only the properties you need defined.
It's attempting to serialize references to other tables that are part of your model.
Upvotes: 0
Reputation: 20203
This issue is N1 starting problem and discussed on many forums. I suggest you to start with the documentation troubleshooting topic.
Upvotes: 0