Hi,
I'm sorry it's taken me so long to reply to this. I can't share the actual source code, nor can I produce videos on my dev computer -- but I can provide a very simple sample Razor component that demonstrates the issue. I'm pasting it below, and also including it as a .ZIP file along with a screencap showing the exception (which occurs when you open the component and try to edit any cell in the grid).
The core issue is that the SfGrid is trying to touch all properties of the model class, not just the ones referenced as GridColumn objects. This works fine in simple test code, but in practice data objects often have properties that for various reasons cannot be read or set at all times. Since the SfGrid isn't set up to do anything with PropertyC, it should not try to touch PropertyC.
Your suggestions for BeforeAdd and CellEdit are useful in the case where the model class does not have a parameterless public constructor, but they don't seem to help for the case where the model class has properties that the code should not touch.
@page "/itererr"
@using Syncfusion.Blazor.Grids
<h3>IterationPropertyError</h3>
@if (Data == null)
{
<p><em>Loading...</em></p>
}
else
{
<SfGrid DataSource="@Data">
<GridColumns>
<GridColumn HeaderText="Column A" Field="PropertyA" />
<GridColumn HeaderText="Column B" Field="PropertyB" />
<!-- Explicitly note that there is no reference to PropertyC, so it should
not be touched. -->
</GridColumns>
<GridEditSettings AllowAdding="true"
AllowDeleting="true" ShowDeleteConfirmDialog="false"
AllowEditing="true" AllowEditOnDblClick="true" />
</SfGrid>
}
@code {
public ModelClass[] Data = new ModelClass[]
{ new ModelClass("A1","B1","C1") ,
new ModelClass("A2","B2","C2") };
public class ModelClass
{
private string _a, _b, _c;
public ModelClass(string A, string B, string C)
{ _a = A; _b = B; _c = C; }
public ModelClass()
{ _a = null; _b = null; _c = null; }
public string PropertyA
{ get { return _a; }
set { _a = value; } }
public string PropertyB
{ get { return _b; }
set { _b = value; } }
public string PropertyC
{ get { throw new Exception("This property is inaccessible at present."); }
set { throw new Exception("This property is inaccessible at present."); } }
}
}
Attachment:
IterationPropertyError_23237126.zip