Hello,
I'm new to Radzen, but what I would like to do is to unable a column when the row is on insert and disable this one when updating ( it's the key column and unfortunately this one is not and identity column but a char one).
I've found readonly tag but would like to know if it's possible to disable a part of the html ?
ie:
<EditTemplate Context="pays">
<RadzenTextBox @bind-Value="pays.Code_Pays" Style="width:100%; display: block" Name="Code_Pays" ReadOnly="@(!IsUpdating)"/>
<RadzenRequiredValidator Text="Le Code du pays est requis" Component="Code_Pays" Popup="true" />
</EditTemplate>
Thanks
Hi @olefevre,
Do you want to enable the textbox only when adding items? Then you can use some property of the context which will be (or not be) set during insert. For example say the ID property is set to 0 for items that are not yet inserted then you can use the following to make the textbox disabled:
<EditTemplate Context="pays">
<RadzenTextBox ReadOnly="@(pays.ID != 0)" @bind-Value="pays.Code_Pays" Style="width:100%; display: block" Name="Code_Pays" />
<RadzenRequiredValidator Text="Le Code du pays est requis" Component="Code_Pays" Popup="true" />
</EditTemplate>
Hi @korchev ,
Thank you for your reply, yes it's what I've done with a property in code.
But what I would like to do is, not to show the TextBox like a visible or somehing like :
@code( if (some property)
{
<RadzenTextBox ReadOnly="@(pays.ID != 0)" @bind-Value="pays.Code_Pays" Style="width:100%; display: block" Name="Code_Pays" />
})
Regards
You can use the Blazor @if()
block or just set the Visible property of the RadzenTextBox.
Sorry in facts there's a strange behavior.
Here is my code :
@if (IsUpdating)
{
<RadzenDataGridColumn Width="100px" TItem="Payan.Providers.ICommun.Models.Pays" Property="Code_Pays" Title="Code Pays">
<EditTemplate Context="pays">
<RadzenTextBox @bind-Value="pays.Code_Pays" Style="width:100%; display: block" Name="Code_Pays" @*ReadOnly="@( !string.IsNullOrWhiteSpace(pays.Code_Pays))"*@ />
<RadzenRequiredValidator Text="Le Code du pays est requis" Component="Code_Pays" Popup="true" />
</EditTemplate>
</RadzenDataGridColumn>
}
else
{
<RadzenDataGridColumn Width="100px" TItem="Payan.Providers.ICommun.Models.Pays" Property="Code_Pays" Title="Code Pays" />
}
This column is the first one in the datagrid and when editing it goes at the end of the DataGrid .
Regards
Try putting the if inside the EditTemplate.