diff --git a/src/Connected.Components/Components/SimpleSelect.razor b/src/Connected.Components/Components/SimpleSelect.razor
index facc072..2d895a7 100644
--- a/src/Connected.Components/Components/SimpleSelect.razor
+++ b/src/Connected.Components/Components/SimpleSelect.razor
@@ -4,15 +4,22 @@
@inherits InputBase;
-
+}
\ No newline at end of file
diff --git a/src/Connected.Components/Components/SimpleSelect.razor.cs b/src/Connected.Components/Components/SimpleSelect.razor.cs
index 4bdfdc2..d94a841 100644
--- a/src/Connected.Components/Components/SimpleSelect.razor.cs
+++ b/src/Connected.Components/Components/SimpleSelect.razor.cs
@@ -1,5 +1,6 @@
using Connected.Models;
using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Web;
using System;
namespace Connected.Components;
@@ -9,30 +10,51 @@ public partial class SimpleSelect : InputBase
public ValueType Value { get; set; }
[Parameter]
- public IEnumerable> Items { get; set; }
+ public IEnumerable Items { get; set; }
- public IEnumerable> OriginalItems { get; set; }
+ public IEnumerable OriginalItems { get; set; }
[Parameter]
public bool EnableSearch { get; set; } = true;
- public string SearchText { get; set; }
- public void FilterItems()
+ private string _searchText { get; set; } = string.Empty;
+ public string SearchText
{
- Items= Items.Where(item => item.Value.ToString().ToLower().Contains(SearchText.ToLower()) || item.DisplayedText.ToString().ToLower().Contains(SearchText.ToLower()));
+ get
+ {
+ return _searchText;
+ }
+ set
+ {
+ _searchText = value;
+ FilterItems();
+ }
+ }
+
+ private async Task FilterItems()
+ {
+ if (string.IsNullOrEmpty(_searchText))
+ {
+ Items = OriginalItems;
+ }
+ else
+ {
+ Items = Items.Where(item => item.ToString().ToLower().Contains(_searchText.ToLower()));
+ }
+ StateHasChanged();
}
- [Parameter]
- public EventCallback ValueChanged { get; set; }
+ [Parameter]
+ public EventCallback ValueChanged { get; set; }
- private async Task ChangeValueAsync(ChangeEventArgs args)
- {
- await ValueChanged.InvokeAsync((ValueType)Convert.ChangeType(args.Value, typeof(ValueType)));
- }
+ private async Task ChangeValueAsync(ChangeEventArgs args)
+ {
+ await ValueChanged.InvokeAsync((ValueType)Convert.ChangeType(args.Value, typeof(ValueType)));
+ }
protected override async Task OnParametersSetAsync()
- {
+ {
if (base.InputAttributes is null) base.InputAttributes = new();
if (base.Required)
{
@@ -40,6 +62,5 @@ public partial class SimpleSelect : InputBase
}
OriginalItems = Items;
await base.OnInitializedAsync();
- }
-
+ }
}
\ No newline at end of file