Skip to content

Commit 0c90913

Browse files
kendo-botKB Botntachevaikoevskadimodi
authored
Added new kb article common-kb-stackoverflowexception-editing-circular-references (#2328)
* Added new kb article common-kb-stackoverflowexception-editing-circular-references * Update knowledge-base/common-kb-stackoverflowexception-editing-circular-references.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update knowledge-base/common-kb-stackoverflowexception-editing-circular-references.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update knowledge-base/common-kb-stackoverflowexception-editing-circular-references.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update knowledge-base/common-kb-stackoverflowexception-editing-circular-references.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update knowledge-base/common-kb-stackoverflowexception-editing-circular-references.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * chore(common): address feedback * Update knowledge-base/common-stackoverflowexception-editing-circular-references.md Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com> * chore(common): link foreign key column kb --------- Co-authored-by: KB Bot <kb-bot@telerik.com> Co-authored-by: Nadezhda Tacheva <73842592+ntacheva@users.noreply.github.com> Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> Co-authored-by: Nadezhda Tacheva <Nadezhda.Tacheva@progress.com> Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com>
1 parent 1087dce commit 0c90913

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: StackOverflowException When Editing Items with Circular References in Grid for Blazor
3+
description: This article describes how to avoid a StackOverflowException by modifying object properties to prevent circular references when editing items in the Grid, ListView or TreeList for Blazor.
4+
type: troubleshooting
5+
page_title: Editing Items with Circular References in Grid for Blazor Throws StackOverflowException
6+
slug: common-kb-stackoverflowexception-editing-circular-references
7+
tags: telerik, blazor, grid, gantt, listview, scheduler, treelist, stackoverflowexception, circular reference, editing
8+
res_type: kb
9+
ticketid: 1660663, 1592634
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>Grid for Blazor, <br />Gantt for Blazor, <br/>ListView for Blazor, <br />Scheduler for Blazor<br />TreeList for Blazor</td>
19+
</tr>
20+
</tbody>
21+
</table>
22+
23+
## Description
24+
25+
I get a `StackOverflowException` when attempting to edit an item in the Grid for Blazor. The issue occurs when I have circular references in the data items.
26+
27+
## Cause
28+
29+
The Telerik data-bound components that allow editing (for example Grid, ListView, TreeList, and more) create a copy of the original object when the user initiates editing.
30+
31+
The internal cloning algorithm uses reflection to loop through the object properties and copy them in the cloned object. When the model contains a self-referencing object property, the cloning logic loops again and again resulting in an infinite reflection loop and this causes the `StackOverflowException` exception.
32+
33+
## Solution
34+
35+
To resolve the `StackOverflowException`, modify the data model to eliminate circular references. Replace object properties that reference other objects within the same model with primitive properties that store unique identifiers. This change prevents the infinite loop during the cloning process.
36+
37+
For example, instead of having a class with a property that references another object:
38+
39+
```csharp
40+
public class Employee
41+
{
42+
public int Id { get; set; }
43+
public Employee Manager { get; set; }
44+
}
45+
```
46+
47+
Modify the class to [include a primitive property that holds a unique identifier]({%slug grids-foreign-key%}):
48+
49+
```csharp
50+
public class Employee
51+
{
52+
public int Id { get; set; }
53+
public int ManagerId { get; set; }
54+
}
55+
```
56+
57+
## See Also
58+
59+
* [Grid Editing]({%slug components/grid/editing/overview%})
60+
* [Gantt Editing]({%slug gantt-tree-editing%})
61+
* [ListView Editing]({%slug listview-editing%})
62+
* [Scheduler Editing]({%slug scheduler-appointments-edit%})
63+
* [TreeList Editing]({%slug treelist-editing-overview%})

0 commit comments

Comments
 (0)