@namespace AntDesign @inherits AntDomComponentBase @using AntDesign.TableModels @using AntDesign.Internal @using AntDesign.Core.Component.ResizeObserver @typeparam TItem
@if (!HidePagination && PaginationPosition.Contains("top")) { if (PaginationTemplate == null) { } else { @PaginationTemplate((PageSize,PageIndex,_total,_paginationClass.Class, EventCallback.Factory.Create(this, HandlePageChange))) } } @if (_fieldModel is not null) { @ChildContent(_fieldModel) }
@if (TitleTemplate != null || Title != null) {
@if (TitleTemplate != null)@TitleTemplate else @Title
}
@if (ScrollY != null) {
@colGroup(this, true) @header()
@colGroup(this, false) @if (_fieldModel is not null) { @ChildContent(_fieldModel) } @body(_showItems) @tfoot()
} else if (ScrollX != null) {
@colGroup(this, true) @header() @if (_fieldModel is not null) { @ChildContent(_fieldModel) } @body(_showItems) @tfoot()
} else {
@colGroup(this, true) @header() @body(_showItems) @tfoot()
}
@if (FooterTemplate != null || Footer != null) { }
@if (!HidePagination && PaginationPosition.Contains("bottom")) { if (PaginationTemplate == null) { } else { @PaginationTemplate((PageSize,PageIndex,_total,_paginationClass.Class, EventCallback.Factory.Create(this, HandlePageChange))) } }
@code { RenderFragment header() { var headerRowAttributes = OnHeaderRow?.Invoke(); return @ @if (_fieldModel is not null) { @if (HeaderTemplate != null) { @HeaderTemplate(_fieldModel) } else { @ChildContent(_fieldModel) } } ; } static RenderFragment colGroup(Table table, bool header) { var realSize = (CssSizeLength)((table as ITable).RealScrollBarSize); return @ @if (_fieldModel is not null) { @table.ChildContent(_fieldModel) } @if (table.ScrollY != null && header) { } ; } RenderFragment body(IEnumerable showItems, RowData parentRowData = null) { var level = (parentRowData?.Level + 1) ?? 0; if (!_hasInitialized) { return builder => { }; } #if NET5_0_OR_GREATER if (UseItemsProvider&&!_isVirtualizeEmpty) { return @ @foreach (var item in ColumnContext.HeaderColumns) { } ; } else #endif if (_total<=0 || showItems == null) { return @ @if (ScrollX != null) { @if (_tableWidth>0) {
@if (EmptyTemplate!=null) { @EmptyTemplate } else { }
} } else { @if (EmptyTemplate!=null) { @EmptyTemplate } else { } } ; } else if (_groupedColumns.Count>0 && level==0) { return _groups.Select((data, index) => GetGroupRowData(data, index, level, parentRowData?.Children)) .ForeachLoop(bodyRow()); } #if NET5_0_OR_GREATER else if (EnableVirtualization) { return @ ; } #endif else { { @*Build will fail without this block*@ } return showItems.Select((data, index) => GetRowData(data, index, level, parentRowData?.Children)) .ForeachLoop(bodyRow()); } } RenderFragment> bodyRow() { return currentRowData => { return @ @{ var currentDataItem = currentRowData.DataItem; var rowAttributes = OnRow?.Invoke(currentRowData); if (OnRowClick.HasDelegate) { rowAttributes ??= new Dictionary(); rowAttributes.TryAdd("onclick", ((Action)delegate { OnRowClick.InvokeAsync(currentRowData); })); } var rowClassName = RowClassName(currentRowData); @if (RowTemplate != null) { @RowTemplate(currentRowData) } else { @ChildContent(currentDataItem.Data) } // When expand button was clicked, would trigger here to add one more child level @if (currentDataItem.HasChildren && currentRowData.Expanded) { currentRowData.Children??=new(); @body(SortFilterChildren(currentDataItem.Children), currentRowData); } @if (!currentDataItem.HasChildren && ExpandTemplate != null && RowExpandable(currentRowData) && currentRowData.Expanded) { @ExpandTemplate(currentRowData) } } ; }; } RenderFragment tfoot() { @if (_summaryRows?.Any() == true) { return@ @foreach (var row in _summaryRows) { @row.ChildContent } ; } return builder => { }; } }