<MudTd Style="text-align: right" DataLabel="Severity">
<MudSelect Dense="true" T="string" Label="Severity" Variant="Variant.Filled" Placeholder="Please Select" Required="true" @bind-Value="rcontext.Severity" @onchange="DoStuff">
<MudSelectItem @onchange="DoStuff" Value="@("Acceptable")"/>
<MudSelectItem Value="@("Tolerable")" />
<MudSelectItem Value="@("Undesirable")" />
<MudSelectItem Value="@("Intolerable")" />
</MudSelect>
</MudTd>
void DoStuff(ChangeEventArgs e)
{
string selectedString = e.Value.ToString();
Console.WriteLine("It is definitely: " + selectedString);
}
I am not able to invoke this function at all DoStuff() I have put in MudSelect and MudSelectItem tags, but none of the onchange or onclick events are getting fired.
Am I missing something.
whole code
@using System.Net.Http.Json
@using BlazorApp4.Shared.Entities
@using BlazorApp4.Client.Extensions
@inject HttpClient httpClient
<style>
.mud-table-cell-custom-group {
font-weight: 500;
}
.mud-table-cell-custom-group-footer {
padding-bottom: 50px;
text-align: right;
}
</style>
<br />
<EditForm OnSubmit="somefunc" Model="@Elements">
<MudTable Breakpoint="Breakpoint.Sm" Height="700px"
Items="@Elements"
GroupBy="@_groupDefinition"
GroupHeaderStyle="@($"background:{Colors.Grey.Lighten4};")"
GroupFooterClass="mb-4"
Dense="true"
Hover="true"
HorizontalScrollbar="true"
Style="width:100%"
Striped ="false"
@bind-SelectedItem="selectedItem1">
<ColGroup>
<col style="width: 5px;" />
<col style="width:30%;"/>
<col style="width:15%;"/>
<col style="width:25%;"/>
<col style="width:15%;"/>
<col style="width:15%;"/>
</ColGroup>
<HeaderContent>
<MudTh><h6><b>Identified Risk</b></h6></MudTh>
<MudTh><h6><b>Yes/No/NA</b></h6></MudTh>
<MudTh><h6><b>Comments & Discussion</b></h6> </MudTh>
<MudTh><h6><b>Likelihood</b> </h6></MudTh>
<MudTh><h6><b>Severity</b></h6></MudTh>
</HeaderContent>
<GroupHeaderTemplate Context="gcontext">
@*working code - <MudTh Class="mud-table-cell-custom-group" colspan="5"><b>@($"{context.GroupName}##{context.Key}##{((context.Items.Sum((e) => e.Rating) >= 5 ) ? "High" : "Low")} ")</b></MudTh> *@
<MudTh Class="mud-table-cell-custom-group" colspan="5"><b>@($"{gcontext.GroupName}##{gcontext.Key}##{gcontext.Items.Syngenta<Questionnaire>(":")} ")</b></MudTh>
</GroupHeaderTemplate>
<RowTemplate Context="rcontext">
@if (true)
{
<MudTd DataLabel="Identified Risk">@((MarkupString)rcontext.IdentifiedRisk)</MudTd>
}
<MudTd Style="text-align: right" DataLabel="Yes/No/NA">
<MudSelect Dense="true" T="string" Label="Answer" Variant="Variant.Filled" Placeholder="Please Select" Required="true" @bind-Value="rcontext.Yes_No_NA">
<MudSelectItem Value="@("Yes")" />
<MudSelectItem Value="@("No")" />
<MudSelectItem Value="@("N/A")" />
</MudSelect>
</MudTd>
<MudTd DataLabel="Comments & Discussion">
@rcontext.Comments_Discussion
</MudTd>
<MudTd Style="text-align: right" DataLabel="Likelihood">
<MudSelect Dense="true" T="string" Label="Likelihood" Variant="Variant.Filled" Placeholder="Please Select" Required="true" @bind-Value="rcontext.Likelihood">
<MudSelectItem Value="@("Improbable")" />
<MudSelectItem Value="@("Possible")" />
<MudSelectItem Value="@("Probable")" />
</MudSelect>
</MudTd>
<MudTd Style="text-align: right" DataLabel="Severity">
<MudSelect Dense="true" T="string" Label="Severity" Variant="Variant.Filled" Placeholder="Please Select" Required="true"
Value="rcontext.Severity" ValueChanged="value => DoStuff(rcontext, value)">
<MudSelectItem Value="@("Acceptable")" />
<MudSelectItem Value="@("Tolerable")" />
<MudSelectItem Value="@("Undesirable")" />
<MudSelectItem Value="@("Intolerable")" />
</MudSelect>
</MudTd>
@code {
void DoStuff(YourContextClass context, string selectedString)
{
context.Severity = selectedString;
Console.WriteLine("It is definitely: " + selectedString);
}
}
</RowTemplate>
</MudTable>
<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Filled" Color="Color.Primary" Class="ml-auto">Register Request and Continue</MudButton>
</EditForm>
@selectedItem1.Likelihood
@*<MudText Inline="true" Class="align-self-center">Selected1: @selectedItem1?.Concati()</MudText>*@
@code {
[Parameter]
public string? QuestionnaireFileName { get; set; }
private TableGroupDefinition<Questionnaire> _groupDefinition = new()
{
GroupName = "Group",
Indentation = false,
Expandable = true,
IsInitiallyExpanded = true,
Selector = (e) => e.GroupBy
};
void DoStuff(string selectedString)
{
Console.WriteLine("It is definitely: " + selectedString);
}
Questionnaire selectedItem1 = new Questionnaire();
private IEnumerable<Questionnaire>? Elements = new List<Questionnaire>();
void somefunc(EditContext ed)
{
StateHasChanged();
}
void DoStuffDup()
{
Console.WriteLine("It is definitely duplicate: ");
}
protected override async Task OnInitializedAsync()
{
Elements = await httpClient.GetFromJsonAsync<List<Questionnaire>>($"api/questions/{QuestionnaireFileName}");
}
}