I have problem with data grid binding, which is not happening when I am using another DataGrid blazor component.
At the bottom is extract from simple example. When I click on RemoveCurrentPerson for last person in list I would like to have currentPerson set to null and data grid with header and no data.
But removing last item from list throws exception:
"Unhandled exception rendering component: Unable to set property 'Value' on object of type 'Radzen.Blazor.RadzenGrid`1[[BlazorAppTest.Models.Person, BlazorAppTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'. The error was: Object reference not set to an instance of an object"
Here is the example:
<RadzenButton Text="Remove current" Click="RemoveCurrentPerson"></RadzenButton>
<RadzenGrid Data="@people" TItem="Person" ColumnWidth="200px"
Value="@currentPerson" RowSelect="(item) => PersonSelected(item)">
<Columns>
<RadzenGridColumn TItem="Person" Property="Id" Title="Id" />
<RadzenGridColumn TItem="Person" Property="Name" Title="Name" />
<RadzenGridColumn TItem="Person" Property="DayOfBirth" Title="Day Of Birth" />
</Columns>
</RadzenGrid>
private List<BlazorAppTest.Models.Person> people;
private Person currentPerson;
void RemoveCurrentPerson()
{
people.Remove(currentPerson);
currentPerson = people.FirstOrDefault();
}
private void PersonSelected(Person item)
{
currentPerson = item;
}
Is there any workaround for this problem?
Thank you in advance.