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

AutoComplete

The input box autocompletes the function

By setting Items data collection when the user types information that is automatically displayed

Demo

In this example, type 123 strings to display the viewing effect, automatically give the component initialization to the auto-prompt dataset, and the dataset does not change

By setting the IsLikeMatch value settings to turn on fuzzy matching of collections, you control whether case is ignored by setting the IgnoreCase

Demo

In this example, type the abc string to display the viewing effect and select all matches in the collection that contain abc and have the same case

By setting the NoDataTip value setting automatically completes the custom prompt message that appears when the data is not found

Demo

In this example, type 567 strings because the autocomplete information center does not display custom prompt information - the data you want is not found

By setting up ValueChanged callback method reorganizes the data collection based on the data entered by the user before prompting for information

Demo

In this example, type any string to display the viewing effect, and automatically complete the component's dynamic changes from the newly obtained prompt dataset based on the string you type

When a component binds in both directions, it automatically determines whether label text is displayed based on the conditions

Demo

The pre-label explicit rules are consistent with the BootstrapInput component of the [portal]

Bidirectional binding displays labels
Bidirectional bindings do not display labels
Customize DisplayText

Set Debounce value turn on debounce

Demo

In this example, please type any string to display the viewing effect. Within the anti shake time, the auto completion component will only send the results to the back end after the last entry, which will greatly improve the performance

Click the dropdown item or Enter trigger the callback

Demo

Set ItemTemplate for customer the dropdown item

Demo

combox with BootstrapInputGroupLabel inside BootstrapInputGroupLabel

Demo
Prev
Prev
Prev
Suffix

Attributes

Loading...
@page "/autocompletes"
@inject IStringLocalizer<AutoCompletes> Localizer

<h3>AutoComplete</h3>

<h4>The input box autocompletes the function</h4>

<DemoBlock Title="Basic usage" Introduction="By setting <code>Items</code> data collection when the user types information that is automatically displayed" Name="Normal">
    <p>In this example, type 123 strings to display the viewing effect, automatically give the component initialization to the auto-prompt dataset, and the dataset does not change</p>
    <div style="width: 200px;">
        <AutoComplete Items="@StaticItems" IsSelectAllTextOnFocus="true" />
    </div>
</DemoBlock>

<DemoBlock Title="Blur queries and ignore case" Introduction="By setting the <code>IsLikeMatch</code> value settings to turn on fuzzy matching of collections, you control whether case is ignored by setting the <code>IgnoreCase</code>" Name="LikeMatch">
    <p>In this example, type the abc string to display the viewing effect and select all matches in the collection that contain abc and have the same case</p>
    <div style="width: 200px;">
        <AutoComplete Items="@StaticItems" IsLikeMatch="true" IgnoreCase="false" />
    </div>
</DemoBlock>

<DemoBlock Title="Custom prompt message" Introduction="By setting the <code>NoDataTip</code> value setting automatically completes the custom prompt message that appears when the data is not found" Name="NoDataTip">
    <p>In this example, type 567 strings because the autocomplete information center does not display custom prompt information - <code>the data you want is not found</code></p>
    <div style="width: 200px;">
        <AutoComplete Items="@StaticItems" NoDataTip="There is nothing" />
    </div>
</DemoBlock>

<DemoBlock Title="Custom candidates" Introduction="By setting up <code>ValueChanged</code> callback method reorganizes the data collection based on the data entered by the user before prompting for information" Name="ValueChanged">
    <p>In this example, type any string to display the viewing effect, and automatically complete the component's dynamic changes from the newly obtained prompt dataset based on the string you type</p>
    <div style="width: 200px;">
        <AutoComplete Items="@Items" ValueChanged="@OnValueChanged" />
    </div>
</DemoBlock>

<DemoBlock Title="The label is displayed" Introduction="When a component binds in both directions, it automatically determines whether label text is displayed based on the conditions" Name="ShowLabel">
    <p>The pre-label explicit rules are consistent with the <code>BootstrapInput</code> component of the <a href='inputs'>[portal]</a></p>
    <Divider Text="Bidirectional binding displays labels" Alignment="Alignment.Left" style="margin: 2rem 0;"></Divider>
    <ValidateForm Model="@Model">
        <AutoComplete Items="@StaticItems" @bind-Value="@Model.Name" ShowLabel="true" />
    </ValidateForm>
    <Divider Text="Bidirectional bindings do not display labels" Alignment="Alignment.Left" style="margin: 2rem 0;" />
    <AutoComplete Items="@StaticItems" @bind-Value="@Model.Name" ShowLabel="false" />
    <Divider Text="Customize DisplayText" Alignment="Alignment.Left" style="margin: 2rem 0;"></Divider>
    <AutoComplete Items="@StaticItems" @bind-Value="@Model.Name" DisplayText="Custom city" ShowLabel="true" />
</DemoBlock>

<DemoBlock Title="Debounce" Introduction="Set <code>Debounce</code> value turn on debounce" Name="Debounce">
    <p>In this example, please type any string to display the viewing effect. Within the anti shake time, the auto completion component will only send the results to the back end after the last entry, which will greatly improve the performance</p>
    <div style="width: 200px;">
        <AutoComplete Items="@Items" ValueChanged="@OnValueChanged" Debounce="500" />
    </div>
</DemoBlock>

<DemoBlock Title="OnSelectedItemChanged" Introduction="Click the dropdown item or <kbd>Enter</kbd> trigger the callback" Name="OnSelectedItemChanged">
    <AutoComplete Items="@StaticItems" OnSelectedItemChanged="OnSelectedItemChanged"></AutoComplete>
    <BlockLogger @ref="Trace" class="mt-3" />
</DemoBlock>

<DemoBlock Title="ItemTemplate" Introduction="Set <code>ItemTemplate</code> for customer the dropdown item" Name="ItemTemplate">
    <AutoComplete Items="@StaticItems">
        <ItemTemplate>
            <div class="d-flex align-items-center">
                <i class="fa-solid fa-bell"></i>
                <span class="flex-fill ms-2">@context</span>
            </div>
        </ItemTemplate>
    </AutoComplete>
</DemoBlock>

<DemoBlock Title="InputGroup" Introduction="combox with <code>BootstrapInputGroupLabel</code> inside <code>BootstrapInputGroupLabel</code>" Name="Group">
    <div class="row g-3">
        <div class="col-12 col-sm-6 col-md-4">
            <BootstrapInputGroup>
                <BootstrapInputGroupLabel DisplayText="Prev" />
                <AutoComplete Items="@StaticItems" OnSelectedItemChanged="OnSelectedItemChanged"></AutoComplete>
            </BootstrapInputGroup>
        </div>
        <div class="col-12 col-sm-6 col-md-4">
            <BootstrapInputGroup>
                <AutoComplete Items="@StaticItems" OnSelectedItemChanged="OnSelectedItemChanged"></AutoComplete>
                <BootstrapInputGroupLabel DisplayText="Prev" />
            </BootstrapInputGroup>
        </div>
        <div class="col-12 col-sm-6 col-md-4">
            <BootstrapInputGroup>
                <BootstrapInputGroupLabel DisplayText="Prev" />
                <AutoComplete Items="@StaticItems" OnSelectedItemChanged="OnSelectedItemChanged"></AutoComplete>
                <BootstrapInputGroupLabel DisplayText="Suffix" />
            </BootstrapInputGroup>
        </div>
    </div>
</DemoBlock>

<AttributeTable Items="@GetAttributes()" />
// 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>
///
/// </summary>
public sealed partial class AutoCompletes
{
    private readonly List<string> _items = new();

    private IEnumerable<string> Items => _items;

    private Foo Model { get; set; } = new Foo() { Name = "" };

    private static List<string> StaticItems => new() { "1", "12", "123", "1234", "12345", "123456", "abc", "abcdef", "ABC", "aBcDeFg", "ABCDEFG" };

    [NotNull]
    private BlockLogger? Trace { get; set; }

    private Task OnSelectedItemChanged(string val)
    {
        Trace.Log($"Value: {val}");
        return Task.CompletedTask;
    }

    private Task OnValueChanged(string val)
    {
        _items.Clear();
        _items.Add($"{val}@163.com");
        _items.Add($"{val}@126.com");
        _items.Add($"{val}@sina.com");
        _items.Add($"{val}@hotmail.com");
        return Task.CompletedTask;
    }

    /// <summary>
    /// 获得属性方法
    /// </summary>
    /// <returns></returns>
    private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
    {
        // TODO: 移动到数据库中
        new AttributeItem() {
            Name = "ShowLabel",
            Description = Localizer["Att1"],
            Type = "bool",
            ValueList = "true|false",
            DefaultValue = "true"
        },
        new AttributeItem() {
            Name = "ChildContent",
            Description = Localizer["Att2"],
            Type = "RenderFragment",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = "ItemTemplate",
            Description = Localizer["AttItemTemplate"],
            Type = "RenderFragment<string>",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = "Items",
            Description = Localizer["Att3"],
            Type = "IEnumerable<string>",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = "NoDataTip",
            Description = Localizer["Att4"],
            Type = "string",
            ValueList = " — ",
            DefaultValue = Localizer["Att4DefaultValue"]!
        },
        new AttributeItem() {
            Name = "DisplayCount",
            Description = Localizer["Att5"],
            Type = "int?",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = "ValueChanged",
            Description = Localizer["Att6"],
            Type = "Action<string>",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem() {
            Name = "IsLikeMatch",
            Description = Localizer["Att7"],
            Type = "bool",
            ValueList = "true|false",
            DefaultValue = "false"
        },
        new AttributeItem()
        {
            Name = "IgnoreCase",
            Description = Localizer["Att8"],
            Type = "bool",
            ValueList = "true|false",
            DefaultValue = "true"
        },
        new AttributeItem()
        {
            Name = "OnCustomFilter",
            Description = Localizer["Att9"],
            Type = "Func<string, Task<IEnumerable<string>>>",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem()
        {
            Name = "Debounce",
            Description = Localizer["Debounce"],
            Type = "int",
            ValueList = " — ",
            DefaultValue = "0"
        },
        new AttributeItem()
        {
            Name = nameof(AutoComplete.SkipEnter),
            Description = Localizer[nameof(AutoComplete.SkipEnter)],
            Type = "bool",
            ValueList = "true/false",
            DefaultValue = "false"
        },
        new AttributeItem()
        {
            Name = nameof(AutoComplete.SkipEsc),
            Description = Localizer[nameof(AutoComplete.SkipEsc)],
            Type = "bool",
            ValueList = "true/false",
            DefaultValue = "false"
        },
        new AttributeItem()
        {
            Name = nameof(AutoComplete.OnValueChanged),
            Description = Localizer[nameof(AutoComplete.OnValueChanged)],
            Type = "Func<string, Task>",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem()
        {
            Name = nameof(AutoComplete.OnSelectedItemChanged),
            Description = Localizer[nameof(AutoComplete.OnSelectedItemChanged)],
            Type = "Func<string, Task>",
            ValueList = " — ",
            DefaultValue = " — "
        }
    };
}

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.0.8-beta05

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