@namespace AntDesign.Internal
@typeparam TItem
@implements IDisposable
@using AntDesign.TableModels
@{ _blockColumns = false; }
@code {
private bool _blockColumns = false;
private RowData _rowData;
[Parameter]
public RowData RowData { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
[Parameter]
public Action, bool> RowDataSelectedChanged { get; set; }
protected override void OnInitialized()
{
_rowData = RowData;
_rowData.SelectedChanged += OnRowDataSelectedChanged;
_rowData.ExpandedChanged += OnRowDataExpandedChanged;
}
protected override void OnParametersSet()
{
if (_rowData != RowData)
{
_rowData.SelectedChanged -= OnRowDataSelectedChanged;
_rowData.ExpandedChanged -= OnRowDataExpandedChanged;
_rowData = RowData;
_rowData.SelectedChanged += OnRowDataSelectedChanged;
_rowData.ExpandedChanged += OnRowDataExpandedChanged;
}
}
private void OnRowDataSelectedChanged(RowData rowData, bool selected)
{
_blockColumns = true;
RowDataSelectedChanged?.Invoke(rowData as RowData, selected);
InvokeAsync(StateHasChanged);
}
private void OnRowDataExpandedChanged(RowData rowData, bool expanded)
{
InvokeAsync(StateHasChanged);
}
void IDisposable.Dispose()
{
_rowData.SelectedChanged -= OnRowDataSelectedChanged;
_rowData.ExpandedChanged -= OnRowDataExpandedChanged;
}
}