Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SearchBox isn't displayed when using RenderFragment instead of ItemCollection #257

Closed
MartinSoka opened this issue Aug 8, 2023 · 2 comments

Comments

@MartinSoka
Copy link

MartinSoka commented Aug 8, 2023

Hi,
i wanted to disable certain items within MudSelectExtended, hence i switched from ItemCollection to RenderFragment display of elements. However it looks like the SearchBox is usable only with ItemCollection. Is this true? If yes what could i do to disable certain elemnts dynamically within the ItemCollection and add text to them (like in the examples using ItemDisabledTemplate)

    <MudItem xs="12" sm="8" Class="d-flex gap-4">
        <MudSelectExtended  T="string" SearchBox="true" SearchBoxAutoFocus=true SearchBoxClearable=true Label="Standard Search" AnchorOrigin="Origin.BottomCenter" Variant="Variant.Outlined" HelperText="Search with 'Contains' logic"> 
          <ChildContent>
             @foreach (var state in _states)
                {
                    <MudSelectItemExtended Value="state" Disabled=@(state.StartsWith('A') ? true : false)>@state</MudSelectItemExtended>
                }   
          </ChildContent>  
        </MudSelectExtended>
    </MudItem>
</MudGrid>


@code {
    private string[] _states =

    {
        "Alabama", "Alaska", "American Samoa", "Arizona",
        "Arkansas", "California", "Colorado", "Connecticut",
        "Delaware", "District of Columbia", "Federated States of Micronesia",
        "Florida", "Georgia", "Guam", "Hawaii", "Idaho",
        "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky",
        "Louisiana", "Maine", "Marshall Islands", "Maryland",
        "Massachusetts", "Michigan", "Minnesota", "Mississippi",
    };

    private bool SearchItems(string value, string searchString)
    {
        if (searchString == "")
        {
            return true;
        }

        if (value.StartsWith(searchString, StringComparison.CurrentCultureIgnoreCase))
        {
            return true;
        }

        return false;
    }
}```
@MartinSoka MartinSoka changed the title SearchBox isn't displayed when using RenderFragment instead ItemCollection SearchBox isn't displayed when using RenderFragment instead of ItemCollection Aug 8, 2023
@MartinSoka
Copy link
Author

thx for the quick reply @mckaragoz I've used ItemDisabledFunc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@MartinSoka and others