mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-05 13:37:35 +08:00
0930f79da8
* feat(module: table): add colspan & rowspan * fix: unit test * test: add colspan and rowspan case Co-authored-by: ElderJames <shunjiey@hotmail.com>
84 lines
2.2 KiB
C#
84 lines
2.2 KiB
C#
@namespace AntDesign
|
|
@inherits ColumnBase
|
|
@using AntDesign.Core.Helpers
|
|
@using AntDesign.TableModels
|
|
@typeparam TData
|
|
|
|
@if (IsPlaceholder)
|
|
{
|
|
<td style="padding: 0px; border: 0px; height: 0px;"></td>
|
|
}
|
|
else if (IsColGroup)
|
|
{
|
|
if (Width > 0)
|
|
{
|
|
<col style="width: @(Width)px; min-width: @(Width)px;">
|
|
}
|
|
}
|
|
else if (IsHeader && HeaderColSpan != 0)
|
|
{
|
|
<th class="@ClassMapper.Class" style="@FixedStyle @Style" @onclick="HandelHeaderClick" colspan="@HeaderColSpan">
|
|
@if (Sortable)
|
|
{
|
|
if (ShowSorterTooltip)
|
|
{
|
|
@ToolTipSorter(this)
|
|
}
|
|
else
|
|
{
|
|
@SortHeader(this)
|
|
}
|
|
}
|
|
else
|
|
{
|
|
@HeaderTitle
|
|
}
|
|
</th>
|
|
}
|
|
else if (RowSpan != 0 && ColSpan != 0)
|
|
{
|
|
<td class="@ClassMapper.Class" style="@FixedStyle @Style" rowspan="@RowSpan" colspan="@ColSpan">
|
|
@if (CellRender != null)
|
|
{
|
|
@CellRender(Field)
|
|
}
|
|
else if (ChildContent != null)
|
|
{
|
|
@ChildContent
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(Format))
|
|
{
|
|
@(Formatter<TData>.Format(Field,Format))
|
|
}
|
|
else
|
|
{
|
|
@Field
|
|
}
|
|
}
|
|
</td>
|
|
}
|
|
|
|
@code
|
|
{
|
|
|
|
string HeaderTitle => Title ?? DisplayName ?? FieldName;
|
|
|
|
readonly RenderFragment<Column<TData>> SortHeader = col =>
|
|
@<div class="ant-table-column-sorters">
|
|
<span>@col.HeaderTitle</span>
|
|
<span class="ant-table-column-sorter ant-table-column-sorter-full">
|
|
<span class="ant-table-column-sorter-inner">
|
|
<Icon Type="caret-up" Class=@($"ant-table-column-sorter-up {(col.SortModel.SortType==SortType.Ascending? "active":"")}") />
|
|
<Icon Type="caret-down" Class=@($"ant-table-column-sorter-down {(col.SortModel.SortType==SortType.Descending? "active":"")}") />
|
|
</span>
|
|
</span>
|
|
</div>;
|
|
|
|
readonly RenderFragment<Column<TData>> ToolTipSorter = col =>
|
|
@<Tooltip Class="ant-table-column-sorters-with-tooltip" Title="@col.SorterTooltip">
|
|
@col.SortHeader(col)
|
|
</Tooltip>;
|
|
|
|
} |