ant-design-blazor/components/table/TableModels/RowData.cs
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

78 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
namespace AntDesign.TableModels
{
public class RowData<TItem> : RowData
{
public TItem Data { get; set; }
internal Dictionary<TItem, RowData<TItem>> Children { get; set; } = new();
public RowData(int rowIndex, int pageIndex, TItem data)
{
this.RowIndex = rowIndex;
this.PageIndex = pageIndex;
this.Data = data;
}
}
public class RowData
{
private bool _selected;
private bool _expanded;
public int RowIndex { get; set; }
public int PageIndex { get; set; }
public bool Selected
{
get => _selected;
set
{
if (_selected != value)
{
_selected = value;
SelectedChanged?.Invoke(this, _selected);
}
}
}
public bool Expanded
{
get => _expanded;
set
{
if (_expanded != value)
{
_expanded = value;
ExpandedChanged?.Invoke(this, _expanded);
}
}
}
public int Level { get; set; }
public int CacheKey { get; set; }
public bool HasChildren { get; set; }
public event Action<RowData, bool> SelectedChanged;
public event Action<RowData, bool> ExpandedChanged;
internal void SetSelected(bool selected)
{
_selected = selected;
}
internal void SetExpanded(bool expanded)
{
_expanded = expanded;
}
}
}