Hello,
I am Trying to display a message under my dropdown list when it is empty like this:
But I can't seem to find the solution.
Can you help m
Here is my grid:
<SfGrid @ref="Grid" DataSource="@Intervenants" Locale="fr" Toolbar="@(new List<string>() {"Add", "Search"})" AllowPaging="true">
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Normal" ShowDeleteConfirmDialog="true"></GridEditSettings>
<GridEvents TValue="IntervenantDto" OnActionBegin="ActionBegin" OnActionComplete="ActionComplete" CommandClicked="CommandClicked"></GridEvents>
<GridColumns>
<GridColumn Field=@nameof(IntervenantDto.Id) HeaderText="Id" IsPrimaryKey="true" IsIdentity="true" Visible="false"></GridColumn>
<GridColumn Field=@nameof(IntervenantDto.Code) HeaderText="Code">
<EditTemplate>
<SfTextBox ID="Code" HtmlAttributes="@(new Dictionary<string, object>() {{"maxlength", 25}})" @bind-Value="@((context as IntervenantDto).Code)"></SfTextBox>
</EditTemplate>
</GridColumn>
<GridColumn Field=@nameof(IntervenantDto.Nom) HeaderText="Nom" EditType="EditType.DefaultEdit">
<EditTemplate>
<SfTextBox ID="Nom" HtmlAttributes="@(new Dictionary<string, object>() {{"maxlength", 50}})" @bind-Value="@((context as IntervenantDto).Nom)"></SfTextBox>
</EditTemplate>
</GridColumn>
<GridColumn Field=@nameof(IntervenantDto.Prenom) HeaderText="Prénom">
<EditTemplate>
<SfTextBox ID="Prenom" HtmlAttributes="@(new Dictionary<string, object>() {{"maxlength", 50}})" @bind-Value="@((context as IntervenantDto).Prenom)"></SfTextBox>
</EditTemplate>
</GridColumn>
<GridColumn Field=@nameof(IntervenantDto.Courriel) HeaderText="Courriel">
<EditTemplate>
<SfTextBox ID="Courriel" HtmlAttributes="@(new Dictionary<string, object>() {{"maxlength", 200}})" @bind-Value="@((context as IntervenantDto).Courriel)"></SfTextBox>
</EditTemplate>
</GridColumn>
<GridColumn HeaderText="Rôle" Width="200" EditType="EditType.DropDownEdit">
<Template>
@{
if (Roles!=null && Roles.Any())
{
var intervenant = (context as IntervenantDto);
var role = Roles.First(a => a.Id == intervenant.RoleId);
<span>@role?.Description</span>
}
}
</Template>
<EditTemplate>
<SfDropDownList ID="roles" Placeholder="choisir un rôle" @bind-Value="@((context as IntervenantDto).RoleId)" TValue="int?" TItem="Role" DataSource="@Roles">
<DropDownListFieldSettings Text="Description" Value="Id"></DropDownListFieldSettings>
</SfDropDownList>
</EditTemplate>
</GridColumn>
<GridColumn HeaderText="" Width="150">
<GridCommandColumns>
<GridCommandColumn Type="CommandButtonType.Edit" ButtonOption="@(new CommandButtonOptions() {IconCss = "e-icons e-edit", CssClass = "e-flat"})"></GridCommandColumn>
<GridCommandColumn Type="CommandButtonType.Delete" ButtonOption="@(new CommandButtonOptions() {IconCss = "e-icons e-delete", CssClass = "e-flat"})"></GridCommandColumn>
<GridCommandColumn Type="CommandButtonType.Save" ButtonOption="@(new CommandButtonOptions() {IconCss = "e-icons e-save", CssClass = "e-flat"})"></GridCommandColumn>
<GridCommandColumn Type="CommandButtonType.Cancel" ButtonOption="@(new CommandButtonOptions() {IconCss = "e-icons e-cancel-icon", CssClass = "e-flat"})"></GridCommandColumn>
</GridCommandColumns>
</GridColumn>
</GridColumns>
</SfGrid>
here is the definition on my class IntervenantDto
and here is the definition of my class Role
Thank you
Hi psyk,
Greetings from Syncfusion support.
We have analyzed your shared codes. We could see that you have not defined any Field property for the Template column(Rôle). We suggest you to ensure to set the Field property value for the column and also ensure to set ID property of SfDropDownList similar to the Field property value to overcome the reported scenario.
We have discussed this in the below documentation. Kindly refer the below documentation and try this from your side.
https://blazor.syncfusion.com/documentation/datagrid/how-to/editing-with-template-column
Please get back to us if you need further assistance.
Regards,
Renjith R