mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 01:11:52 +08:00
71bac2e85d
* Children components using CascadingParameter add itself to parent component.However, when children components disposed, they are not remove from parent component. For example, when items in checkgroup have changed , it may causes Index was outside the bounds of the array at AntDesign.CheckboxGroup.OnCheckboxChange.To fix these bug, Adding remove function in dispose process is the solution of this commit. * fix: some exception Co-authored-by: ElderJames <shunjiey@hotmail.com>
76 lines
1.6 KiB
C#
76 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
#pragma warning disable 1591
|
|
|
|
namespace AntDesign
|
|
{
|
|
public partial class SelectOptGroup : AntDomComponentBase
|
|
{
|
|
#region Private
|
|
private const string ClassNamePrefix = "ant-select-item-group";
|
|
#endregion
|
|
|
|
#region Protected
|
|
#region Properties
|
|
|
|
protected IList<SelectOption> SelectOptions { get; set; } = new List<SelectOption>();
|
|
|
|
#endregion Properties
|
|
|
|
#region Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
SetClassMap();
|
|
base.OnInitialized();
|
|
}
|
|
|
|
protected void SetClassMap()
|
|
{
|
|
ClassMapper.Clear()
|
|
.Add("ant-select-item")
|
|
.Add(ClassNamePrefix);
|
|
}
|
|
|
|
#endregion Methods
|
|
|
|
#endregion Protected
|
|
|
|
#region Public
|
|
|
|
#region Properties
|
|
|
|
#region Parameters
|
|
[Parameter] public string Key { get; set; }
|
|
|
|
[Parameter] public string Label { get; set; }
|
|
|
|
[CascadingParameter] public Select Parent { get; set; }
|
|
|
|
[Parameter] public RenderFragment ChildContent { get; set; }
|
|
|
|
#endregion Parameters
|
|
|
|
#endregion Properties
|
|
|
|
#region Methods
|
|
|
|
public void AddOption(SelectOption option)
|
|
{
|
|
SelectOptions.Add(option);
|
|
Parent.AddOption(option);
|
|
}
|
|
|
|
public void RemoveOption(SelectOption option)
|
|
{
|
|
SelectOptions.Remove(option);
|
|
Parent.RemoveOption(option);
|
|
}
|
|
|
|
#endregion Methods
|
|
|
|
#endregion Public
|
|
}
|
|
}
|