ant-design-blazor/components/table/TableRowWrapper.razor
rhodon-jargon cb88c530a8
fix(module: table): Incorrect deselection in virtualized table (#3282)
* fix(module: table): Correctly deselect all rows in radio selection with a virtualized table

* Implement internal inteface method correctly

* fix(module: table): Fix correctly rerendering selection components, selecting tree data

* Add documentation comments

* Fix bind-SelectedRows

---------

Co-authored-by: Rhodon <rhodonvantilburg@gmail.com>
Co-authored-by: James Yeung <shunjiey@hotmail.com>
2023-10-21 23:45:37 +08:00

59 lines
1.6 KiB
C#

@namespace AntDesign.Internal
@typeparam TItem
@implements IDisposable
@using AntDesign.TableModels
<CascadingValue Value="_blockColumns" Name="AntDesign.Column.Blocked">
<CascadingValue Value="_rowData" Name="RowData" ChildContent="ChildContent" />
</CascadingValue>
@{ _blockColumns = false; }
@code {
private bool _blockColumns = false;
private RowData<TItem> _rowData;
[Parameter]
public RowData<TItem> RowData { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
protected override void OnInitialized()
{
_rowData = RowData;
_rowData.DataItem.SelectedChanged += OnRowDataSelectedChanged;
_rowData.ExpandedChanged += OnRowDataExpandedChanged;
}
protected override void OnParametersSet()
{
if (_rowData != RowData)
{
_rowData.DataItem.SelectedChanged -= OnRowDataSelectedChanged;
_rowData.ExpandedChanged -= OnRowDataExpandedChanged;
_rowData = RowData;
_rowData.DataItem.SelectedChanged += OnRowDataSelectedChanged;
_rowData.ExpandedChanged += OnRowDataExpandedChanged;
}
}
private void OnRowDataSelectedChanged(TableDataItem rowData, bool selected)
{
_blockColumns = true;
InvokeAsync(StateHasChanged);
}
private void OnRowDataExpandedChanged(RowData rowData, bool expanded)
{
InvokeAsync(StateHasChanged);
}
void IDisposable.Dispose()
{
_rowData.DataItem.SelectedChanged -= OnRowDataSelectedChanged;
_rowData.ExpandedChanged -= OnRowDataExpandedChanged;
}
}