I try to create my own table component using @typeparam TItem. I'd like to show my data in an EditForm as inputs.
If i want to show simple data i do something like this:
<Virtualize Context="item" Items="FilteredDataItems">
<tr>
@foreach(var column in columns)
{
<td>
@GetValue(item, column)
</td>
}
</tr>
</Virtualize>
And it's fine. The GetValue function check what type is column and return value in correct format.
But I dont know what to do to show data in EditForm (because of TItem). I try something like this below but i doesn't work:
<Virtualize Context="item" Items="FilteredDataItems">
<tr>
<EditForm Model="item">
<DataAnnotationsValidator />
@foreach(var column in columns)
{
<td>
@switch(column.DataType)
{
case DataType.Text:
<InputText @bind-Value="((string)typeof(TItem).GetProperty(column.PropertyName)?.GetValue(item))" />
break;
case DataType.Decimal:
<InputText @bind-Value="Convert.ToDecimal(typeof(TItem).GetProperty(column.PropertyName)?.GetValue(item))" />
break;
}
</td>
}
</EditForm>
</tr>
</Virtualize>
Have You any idea how should it looks like (for work and compiler)? Best regards.