In an inherited RadzenDataGridColumn editTempalte does not apply validation CSS classes

Hi,

I try to create a custom RadzenDataGridColumn, where the EditorTemplate is prefilled with a RadzenTextField based on the column Property.

My inheteded Colum is very simple just wraps the Textbox with a FormField, see the code below.

@typeparam TItem
@inherits RadzenDataGridColumn<TItem>

@{
    EditTemplate = rowData =>
         @<RadzenFormField Text="@Title" Variant="Variant.Text">
            <RadzenTextBox Value="@((string?)PropertyAccess.GetValue(rowData, Property))" 
                           ValueChanged="@(value => rowData.SetValue(Property, value))" />
         </RadzenFormField>;
}

When I use MyColumn, in edit mode, the validation CSS classes are not applied to the textbox (the gird uses FluentValidation with NotEmpty constraint). The validation works, as I see the validation message, and the column that was created on the standard way has the validation CSS classes, but that is inside MyColumn is not highligted.

The first 'Kulcs' column is created on the standard way, the second 'Kulcs' column uses MyColumn.

<RadzenDataGridColumn TItem="TCreateOrEditTranslation" Property="@nameof(CreateOrEditTranslation.Key)" Title="Kulcs">
    <EditTemplate>
        <RadzenFormField Text="Kulcs" Variant="Variant.Text">
            <RadzenTextBox @bind-Value="@context.Key" />
        </RadzenFormField>
    </EditTemplate>
</RadzenDataGridColumn>

<MyColumn TItem="TCreateOrEditTranslation" Property="@nameof(CreateOrEditTranslation.Key)" Title="Kulcs" />

How should I create the data binding of the RadzenTextBox in MyColumn?
@bind-Value would be the best, but I do not have the Property and expression cannot be used. With Value + ValueChanged I cannot access the EditContext to call NotifyFieldChanged or NotifyValidationStateChanged.

Blazor validation works only with @bind-Value.

Is it possible to use @bind-Value in MyColumn. How?

There is nothing that prevents you to do it.

In my case this would be the following.

RenderFragment<TItem> textbox = rowData =>
     @<RadzenTextBox @bind-Value="@rowData.Property" />;

But Property is a parameter of the DataGridColumn and that is only a string. Saidly in @bind-Value Expressions or dynamic types cannot be used there.

Do you have any idea what should I write for the @bind-Value?

You can check Microsoft Blazor documentation on how to create @bind-Value expression with code.

Ok, so it is not possible to extend a DataGridColumn, with predefined EditTemapte that uses data binding. Or at least there is not any demo or test case for it.

Thank you. I continue searching for a solution...

And a last question. Are you planning to create such a demo page?

No, that’s not true.

We don’t plan to create such example. Check the obj folder of your Blazor application how the .razor code and especially @bind-Value is translated to C#.