logo Enterprise-level component library based on Bootstrap and Blazor
gitee
version
license
download
repo
commit
build
coverage

CheckboxList

The control is used to create a multi-select check box group

Show check box groups by data binding

Demo
  • Set bidirectional binding data value through bind-Value
  • Set candidate data sources through Items
  • Get the changed item instance through the onSelectedChanged callback method

Built in validateform

Demo

You can experience adaptive layout by changing the window size

In this example, the Name field of the binding model binditem is automatically changed by checking the option

Because it is built into the ValidateForm form, in this example, RequiredAttribute required for verification is added. When all options are cancelled, the verification result will be prompted

Pat,Argo

ShowLabelIntro

Demo

Tvalue is set to IEnumerable<int> generic collection, the ValueField specified field of the bound collection must be consistent with the generic type

9,10

TValue is set to IEnumerable<string> generic collection

13,15

The binding value is enumeration

Demo

When CheckboxList binds an enumeration set, Items does not need to be specified, Items will be automatically set to all values in the enumeration. If you need to bind some values, please provide the enumeration set Items

Middle,Primary

By setting ShowBorder='false' do not display borders

Demo

Displays a red border when validation fails

Arrange checkboxes vertically by setting IsVertical = 'true'

Demo

Disable by setting IsDisabled='true'

Demo

Attributes

Loading...

Event

Loading...
@page "/checkboxlists"

<h3>CheckboxList</h3>

<h4>The control is used to create a multi-select check box group</h4>

<DemoBlock Title="Basic usage" Introduction="Show check box groups by data binding" Name="Normal" Demo="typeof(Demos.CheckboxList.CheckboxListNormal)">
    <ul class="ul-demo mb-3">
        <li>Set bidirectional binding data value through <code>bind-Value</code ></li>
        <li>Set candidate data sources through <code>Items</code></li>
        <li>Get the changed item instance through the <code>onSelectedChanged</code> callback method</li>
    </ul>
</DemoBlock>

<DemoBlock Title="Client Validation" Introduction="Built in validateform" Name="ValidateForm" Demo="typeof(Demos.CheckboxList.CheckboxListValidateForm)">
    <p>You can experience adaptive layout by changing the window size</p>
    <p>In this example, the <code>Name</code> field of the binding model <code>binditem</code> is automatically changed by checking the option</p>
    <p>Because it is built into the <code>ValidateForm</code> form, in this example, <code>RequiredAttribute</code> required for verification is added. When all options are cancelled, the verification result will be prompted</p>
</DemoBlock>

<DemoBlock Title="@Localizer["ShowLabelTitle"]" Introduction="@Localizer["ShowLabelIntro"]" Name="ShowLabel" Demo="typeof(Demos.CheckboxList.CheckboxListShowLabel)">
    <p>Tvalue is set to <code>IEnumerable<int></code> generic collection, the <Code>ValueField</Code> specified field of the bound collection must be consistent with the generic type</p>
</DemoBlock>

<DemoBlock Title="Bidirectional binding enumeration" Introduction="The binding value is enumeration" Name="Enum" Demo="typeof(Demos.CheckboxList.CheckboxListEnum)">
    <p>When <code>CheckboxList</code> binds an enumeration set, <code>Items</code> does not need to be specified, <code>Items</code> will be automatically set to all values in the enumeration. If you need to bind some values, please provide the enumeration set <code>Items</code></p>
</DemoBlock>

<DemoBlock Title="No border" Introduction="By setting <code>ShowBorder='false'</code> do not display borders" Name="NoBorder" Demo="typeof(Demos.CheckboxList.CheckboxListNoBorder)">
    <p>Displays a red border when validation fails</p>
</DemoBlock>

<DemoBlock Title="Vertical arrangement" Introduction="Arrange checkboxes vertically by setting <code>IsVertical = 'true' </code >" Name="Vertical" Demo="typeof(Demos.CheckboxList.CheckboxListVertical)" />

<DemoBlock Title="Disable" Introduction="Disable by setting <code>IsDisabled='true'</code>" Name="Disabled" Demo="typeof(Demos.CheckboxList.CheckboxListDisabled)" />

<AttributeTable Items="@GetAttributes()" />

<EventTable Items="@GetEvents()" />
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.Shared.Samples;

/// <summary>
/// CheckboxLists
/// </summary>
public partial class CheckboxLists
{
    [Inject]
    [NotNull]
    private IStringLocalizer<CheckboxLists>? Localizer { get; set; }

    private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
    {
        new AttributeItem() {
            Name = "Items",
            Description = Localizer["Att1"],
            Type = "IEnumerable<SelectedItem>",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = "IsDisabled",
            Description = Localizer["Att1"],
            Type = "boolean",
            ValueList = " — ",
            DefaultValue = "false"
        },
        new AttributeItem(){
            Name = "Value",
            Description = Localizer["Att1"],
            Type = "TValue",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem(){
            Name = "IsVertical",
            Description = Localizer["Att1"],
            Type = "boolean",
            ValueList = " true / false ",
            DefaultValue = " false "
        }
    };

    /// <summary>
    /// Get event method
    /// </summary>
    /// <returns></returns>
    private IEnumerable<EventItem> GetEvents() => new EventItem[]
    {
        new EventItem()
        {
            Name = "OnSelectedChanged",
            Description = Localizer["Event1"],
            Type ="Func<IEnumerable<SelectedItem>, TValue, Task>"
        }
    };
}

B station related video link

No

交流群

QQ Group:BootstrapAdmin & Blazor 795206915 675147445 Welcome to join the group discussion
img
Themes
Bootstrap
Motronic
Ant Design (完善中)
DevUI (制作中)
LayUI (完善中)
An error has occurred. This application may no longer respond until reloaded. Reload
Seems like the connection with the server has been lost. It can be due to poor or broken network. Please hang on while we're trying to reconnect...
Oh snap! Failed to reconnect with the server. This is typically caused by a longer network outage, or if the server has been taken down. You can try to reconnect, but if that does not work, you need to reload the page.
Oh man! The server rejected the attempt to reconnect. The only option now is to reload the page, but be prepared that it won't work, since this is typically caused by a failure on the server.
Bootstrap Blazor Component library updated to 7.2.5-beta02

Bootstrap Blazor at present has more than 120 components. This component is based on Bootstrap Blazor An enterprise-level component library that provides several types of common components such as layout, navigation, form, data, notification, icon, voice, etc. Each component has been carefully designed with modularity, responsiveness and excellent performance. Starting from more practical scenarios, meeting the needs of various scenarios, greatly reducing the time cost of developers, greatly shortening the development cycle, greatly improving development efficiency, and providing a set of General Rights Management System Example project。Bootstrap Blazor Products are maintained by a professional full-time technical team, with efficient response speed, diversified solutions, long-term support, and enterprise-level support. At present, it has been used in many well-known state-owned enterprises, and the project is running stably with a maximum of 1200 people online. On the right is the QR code of the Chinese Blazor QQ community with the largest number of people in China, welcome to scan and join the group.

component updated to 6.6.0 Change log [portal] If the component brings you convenience, please help to light up the project Star github gitee

QQGroup
QQ 795206915