ant-design-blazor/components/table/TableRowWrapper.razor
Hao Sun 78b10019e4 feat(module: table): add table virtualization (#2143)
* feat(module:table): virtualizing

* turn off virtualizing by default

* add document and demo

* NET_6_0 => NET6_0

* update table selection

* update Table.razor.cs

* update table files

* Update table files

* update table files

* update table files

* update table files

* update table files

* update table files

* update table files

* update Virtualizing.razor

* Update AntDesign.csproj

* Update TableRow.razor

* update files

* Update AntDesign.csproj

* update table files

* update Virtualizing.razor

* add DefaultExpandMaxLevel

* rename Virtualizing to EnableVirtualization

Co-authored-by: James Yeung <shunjiey@hotmail.com>
2022-05-28 13:41:01 +08:00

63 lines
1.7 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; }
[Parameter]
public Action<RowData<TItem>, 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<TItem>, selected);
InvokeAsync(StateHasChanged);
}
private void OnRowDataExpandedChanged(RowData rowData, bool expanded)
{
InvokeAsync(StateHasChanged);
}
void IDisposable.Dispose()
{
_rowData.SelectedChanged -= OnRowDataSelectedChanged;
_rowData.ExpandedChanged -= OnRowDataExpandedChanged;
}
}