mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-02 12:07:44 +08:00
fix(module: checkbox): default value for options (#525)
This commit is contained in:
parent
84a3b742c2
commit
b2231305f2
@ -1,36 +1,42 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using System.Linq.Expressions;
|
|
||||||
|
|
||||||
namespace AntDesign
|
namespace AntDesign
|
||||||
{
|
{
|
||||||
public partial class Checkbox : AntInputComponentBase<bool>
|
public partial class Checkbox : AntInputComponentBase<bool>
|
||||||
{
|
{
|
||||||
[Parameter]
|
[Parameter] public RenderFragment ChildContent { get; set; }
|
||||||
public RenderFragment ChildContent { get; set; }
|
|
||||||
|
|
||||||
private ElementReference _inputElement;
|
private ElementReference _inputElement;
|
||||||
private ElementReference _contentElement;
|
private ElementReference _contentElement;
|
||||||
|
private bool _checked;
|
||||||
|
|
||||||
|
[Parameter] public EventCallback<bool> CheckedChange { get; set; }
|
||||||
|
|
||||||
|
[Parameter] public Expression<Func<bool>> CheckedExpression { get; set; }
|
||||||
|
|
||||||
|
[Parameter] public bool AutoFocus { get; set; }
|
||||||
|
|
||||||
|
[Parameter] public bool Disabled { get; set; }
|
||||||
|
|
||||||
|
[Parameter] public bool Indeterminate { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public EventCallback<bool> CheckedChange { get; set; }
|
public bool Checked
|
||||||
|
{
|
||||||
[Parameter]
|
get => _checked;
|
||||||
public Expression<Func<bool>> CheckedExpression { get; set; }
|
set
|
||||||
|
{
|
||||||
[Parameter]
|
if (_checked != value)
|
||||||
public bool AutoFocus { get; set; }
|
{
|
||||||
|
_checked = value;
|
||||||
[Parameter]
|
CurrentValue = value;
|
||||||
public bool Disabled { get; set; }
|
}
|
||||||
|
}
|
||||||
[Parameter]
|
}
|
||||||
public bool Indeterminate { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public bool Checked { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Label { get; set; }
|
public string Label { get; set; }
|
||||||
@ -76,7 +82,7 @@ namespace AntDesign
|
|||||||
protected override void OnValueChange(bool value)
|
protected override void OnValueChange(bool value)
|
||||||
{
|
{
|
||||||
base.OnValueChange(value);
|
base.OnValueChange(value);
|
||||||
this.Checked = value;
|
this._checked = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task InputCheckedChange(ChangeEventArgs args)
|
protected async Task InputCheckedChange(ChangeEventArgs args)
|
||||||
@ -97,7 +103,6 @@ namespace AntDesign
|
|||||||
await this.CheckedChange.InvokeAsync(@checked);
|
await this.CheckedChange.InvokeAsync(@checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.CheckedChange.InvokeAsync(@checked);
|
|
||||||
CheckboxGroup?.OnCheckboxChange(this);
|
CheckboxGroup?.OnCheckboxChange(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,11 @@
|
|||||||
{
|
{
|
||||||
@foreach (var option in Options.AsT0)
|
@foreach (var option in Options.AsT0)
|
||||||
{
|
{
|
||||||
|
option.Checked = option.Value.IsIn(_selectedValues);
|
||||||
|
|
||||||
<Checkbox class="ant-checkbox-group-item"
|
<Checkbox class="ant-checkbox-group-item"
|
||||||
Disabled="option.Disabled || Disabled"
|
Disabled="option.Disabled || Disabled"
|
||||||
Checked="@(option.Checked)"
|
Checked="@option.Checked"
|
||||||
Label="@option.Value"
|
Label="@option.Value"
|
||||||
CheckedChange="_=>OnCheckedChange()">
|
CheckedChange="_=>OnCheckedChange()">
|
||||||
<span>@option.Label</span>
|
<span>@option.Label</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user