🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

BlazorMultiselectComponent

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

BlazorMultiselectComponent

A multiselect component which supports binding to a collection of any type.

1.0.5
NuGet
Version published
Maintainers
1
Created
Source

Blazor Multiselect Component

I built this component because I found the collection binding to InputSelect tedious. This component allows you to bind complex types to a simple multiselect.

PARAMETERS

TOption Type

The type for the collection being passed to the component.

Label string

The text that labels the multiselect input box on the page.

Options ICollection?

A collection of all of the possible options for the component to display.

DisplayField string

The string name of the property to use when displaying the options.
Preferred way of passing this parameter is by nameof(Model.Property).

SelectedChanged EventCallback<ICollection>

The callback which is invoked whenever the underlying value is updated.

Selected ICollection

The value that the component holds.

HOW TO USE

Inside of an EditForm, bind your collection to the BlazorMultiSelectComponent.

Say we have a product with a list of categories:

    class ProductCategory {
        public int Id { get; set; } 
        public string Name { get; set; }
    }
    class Product {
        ...
        public virtual ICollection<ProductCategory> Categories { get; set; } = new List<ProductCategory>();
        ...
    }

    protected List<ProductCategory> AllCategories { get; set; } = new List<ProductCategory>()
    {
        new ProductCategory
        {
            Id = 1,
            Name = "Category 1"
        },
        new ProductCategory
        {
            Id = 2,
            Name = "Category 2"
        },
        new ProductCategory
        {
            Id = 3,
            Name = "Category 3"
        }
    };

    protected Product Product { get; set; } = new Product();

Bind it to the component like so:

<EditForm>
    ...
    <BlazorMultiSelectComponent.MultiSelect @bind-Selected=@(Product.Categories) Label="Categories" DisplayField=@(nameof(ProductCategory.Name)) Options="AllCategories" />
    ...
</EditForm>

Keywords

blazor

FAQs

Package last updated on 09 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts