Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/KeudellCoding/Blazor.AdvancedBlazorSelect2
Simple wrapper for Select2 with full support of databases and custom web APIs.
https://github.com/KeudellCoding/Blazor.AdvancedBlazorSelect2
blazor blazor-component component html-select select2 selector
Last synced: 3 months ago
JSON representation
Simple wrapper for Select2 with full support of databases and custom web APIs.
- Host: GitHub
- URL: https://github.com/KeudellCoding/Blazor.AdvancedBlazorSelect2
- Owner: KeudellCoding
- License: mit
- Created: 2020-09-03T08:28:02.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-10-24T18:21:08.000Z (9 months ago)
- Last Synced: 2024-02-29T03:49:13.242Z (4 months ago)
- Topics: blazor, blazor-component, component, html-select, select2, selector
- Language: C#
- Homepage: https://www.nuget.org/packages/KeudellCoding.Blazor.AdvancedBlazorSelect2/
- Size: 335 KB
- Stars: 14
- Watchers: 2
- Forks: 4
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Lists
- awesome-blazor - AdvancedBlazorSelect2 - ![last commit](https://img.shields.io/github/last-commit/KeudellCoding/Blazor.AdvancedBlazorSelect2?style=flat-square&cacheSeconds=86400) Simple wrapper for Select2 with full support of databases and custom web APIs. (Libraries & Extensions / Individual components)
README
# Blazor.AdvancedBlazorSelect2
## Installation
1. Install the NuGet package `KeudellCoding.Blazor.AdvancedBlazorSelect2`.
2. Add the following lines to _Host.cshtml (in the head tag)
```html```
3. Make sure [jQuery](https://jquery.com/download/) is installed.
4. Add the following lines to _Imports.razor
```csharp
@using KeudellCoding.Blazor.AdvancedBlazorSelect2
```## Usage Example
```csharp
@page "/"
@inject IMemoryCache __MemoryCache
@inject ApplicationDbContext __DbContext@code {
public class ExampleItemForm {
public Guid Id { get; set; }
public string Text { get; set; }public ExampleItemForm(Guid id, string text) {
Id = id;
Text = text;
}
}//======================================================
public List SelectedItems { get; set; }
//======================================================
private async Task> filterFunction(DbSet allItems, string filter, CancellationToken token) {
return await allItems.Where(i => i.Text.StartsWith(filter)).ToListAsync();
}
}
```## Notes
1. It is ensured that the `SelectedItems` list contains only one item if `Multiselect` is set to `false`.
2. As soon as `SelectedItems` is edited manually, `StateHasChanged();` should be executed.
3. `GetElementById` must be set manually because the process also depends on the data source used.