10 Answers, 1 is accepted
Usually such error may occur when the built-in JSON serializer tries to serialize an object graph which does have circular references. For example type A has a property of type B which has a property of type A.
In order to workaround this problem you may consider using a ViewModel in which such dependencies does not exists. Another approach will be to increase the RecursionLimit.
Rosen
the Telerik team
For example:
@{
Html.Telerik().Grid<
FileInfo
>(Model)
.Name("FileGrid")
.DataKeys(keys => keys.Add(f => f.FullName))
.IgnoreProperties(new string[]{ "Directory", "Attributes" })
.Columns(columns =>
{
columns.Bound(o => o.Name).Width(60);
columns.Bound(o => o.LastWriteTime).Width(60);
})
.DataBinding(dataBinding =>
{
dataBinding.Ajax().Select("_AjaxGrid", "FileModule").Enabled(true);
})
.Footer(true)
.Render();
}
Unfortunately there is no way to tell the JavaScriptSerializer which properties to ignore. The latter is being initialized internally by ASP.NET MVC and we don't have any control over it.
Regards,Atanas Korchev
the Telerik team
No, we don't. The ASP.NET MVC JsonResult class which the grid uses to return the model as JSON creates a JavaScriptSerializer internally which in turn cannot serialize recursive objects.
Regards,Atanas Korchev
the Telerik team
http://james.newtonking.com/projects/json/help/PreserveObjectReferences.html
[ScriptIgnore] // do not serialize to JSON in order to prevent cyclic references
public ICollection<
ConditionPresetFilter
> Filters { get; set; }