Untitled

mail@pastecode.io avatar
unknown
razor
17 days ago
1.2 kB
2
Indexable
Never
    <MudSelectExtended Class="mb-4" T="int?" Label="Select Product Category" Variant="Variant.Outlined" ToStringFunc="GetCategoryString"
                       Immediate="true" @bind-Value="Model.CategoryId" Error="@_productDetailsValidationErrors.ContainsKey(nameof(Model.CategoryId))"
                       @onfocus="ShowSearchBox" OnClose="HideSearchBox">

        @if (_categorySearchVisible)
        {
            <MudTextField T="string" Variant="Variant.Outlined" Immediate="true"
                          AdornmentIcon="@Icons.Material.Filled.Search" AdornmentColor="Color.Primary"
                          Placeholder="Search for a category"/>
        }
        @foreach (var category in Categories)
        {
            <MudSelectItemGroupExtended Class="mud-select-group" T="int?" Text="@category.Name" Nested="true" InitiallyExpanded="@(Categories.IndexOf(category) == 0)">
                @foreach (var subcategory in category.Subcategories)
                {
                    <MudSelectItemExtended Value="@(new int?(subcategory.CategoryId))">
                        @subcategory.Name
                    </MudSelectItemExtended>
                }
            </MudSelectItemGroupExtended>
        }
    </MudSelectExtended>
Leave a Comment