diff --git a/CodeBeam.MudBlazor.Extensions.Docs.Wasm/wwwroot/CodeBeam.MudBlazor.Extensions.xml b/CodeBeam.MudBlazor.Extensions.Docs.Wasm/wwwroot/CodeBeam.MudBlazor.Extensions.xml index d0f56c68..b24c246d 100644 --- a/CodeBeam.MudBlazor.Extensions.Docs.Wasm/wwwroot/CodeBeam.MudBlazor.Extensions.xml +++ b/CodeBeam.MudBlazor.Extensions.Docs.Wasm/wwwroot/CodeBeam.MudBlazor.Extensions.xml @@ -2897,6 +2897,16 @@ Fired on the OnDoubleClick event. + + + If true, a null item will be added to the list (Only for ItemCollection). + + + + + Gets or sets the text displayed for a null item that has been added. + + @@ -4539,6 +4549,16 @@ Defines how values are displayed in the drop-down list + + + If true, a null item will be added to the list (Only for ItemCollection). + + + + + Gets or sets the text displayed for a null item that has been added. + + Set of selected values. If MultiSelection is false it will only ever contain a single value. This property is two-way bindable. diff --git a/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/SelectExtended/Examples/SelectExtendedExample1.razor b/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/SelectExtended/Examples/SelectExtendedExample1.razor index ea6bd709..8fd09237 100644 --- a/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/SelectExtended/Examples/SelectExtendedExample1.razor +++ b/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/SelectExtended/Examples/SelectExtendedExample1.razor @@ -1,16 +1,29 @@ @namespace MudExtensions.Docs.Examples -
- - - - - - + + + + + + + + + + + + + - -
+ + + + + + + @code { - string[] _collection = new string[] { "Foo", "Bar", "Fizz", "Buzz" }; + private bool _disabled = false; + private string[] _collection = new string[] { "Foo", "Bar", "Fizz", "Buzz" }; + private string? _nullItemText = "None"; } \ No newline at end of file diff --git a/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor b/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor index b036134b..1cbcf07d 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor +++ b/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor @@ -41,6 +41,17 @@ } } + @if (AddNullItem) + { + @if (MudSelectExtended != null) + { + + } + else + { + + } + } @if (MudSelectExtended != null) { diff --git a/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs index 9ce6a475..3dc8d33c 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs +++ b/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs @@ -396,6 +396,19 @@ public bool MultiSelection ///
[Parameter] public EventCallback> OnDoubleClick { get; set; } + /// + /// If true, a null item will be added to the list (Only for ItemCollection). + /// + [Parameter] + public bool AddNullItem { get; set; } + + /// + /// Gets or sets the text displayed for a null item that has been added. + /// + [Parameter] + public string? AddedNullItemText { get; set; } = "None"; + + #endregion @@ -740,6 +753,19 @@ protected override void OnInitialized() /// protected override void OnParametersSet() { + //if (ItemCollection != null) + //{ + // var list = ItemCollection.ToList(); + + // if (PopulateOptions == ItemPopulateOptions.AddNullItem) + // { + // if (!list.Contains(default(T))) + // list.Insert(0, default(T)); // null item + // } + + // ItemCollection = list; + //} + base.OnParametersSet(); ParametersChanged?.Invoke(); } diff --git a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor index 26545788..eea67e89 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor +++ b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor @@ -4,7 +4,7 @@ -
+
@@ -126,7 +126,7 @@ @ChildContent @@ -151,7 +151,7 @@ @ChildContent diff --git a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor.cs index 3f21747b..2f9adb1c 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor.cs +++ b/CodeBeam.MudBlazor.Extensions/Components/SelectExtended/MudSelectExtended.razor.cs @@ -522,6 +522,18 @@ public IEqualityComparer? Comparer } } + /// + /// If true, a null item will be added to the list (Only for ItemCollection). + /// + [Parameter] + public bool AddNullItem { get; set; } + + /// + /// Gets or sets the text displayed for a null item that has been added. + /// + [Parameter] + public string? AddedNullItemText { get; set; } = "None"; + #endregion