2020-12-05 18:44:38 +08:00
|
|
|
|
@namespace AntDesign
|
2020-06-19 23:06:33 +08:00
|
|
|
|
@inherits ColumnBase
|
2020-09-06 15:31:40 +08:00
|
|
|
|
@using AntDesign.Core.Helpers
|
2020-07-08 16:12:49 +08:00
|
|
|
|
@using AntDesign.TableModels
|
2020-06-05 16:06:23 +08:00
|
|
|
|
@typeparam TData
|
2020-05-30 01:46:41 +08:00
|
|
|
|
|
2021-01-09 23:57:31 +08:00
|
|
|
|
@if (IsInitialize)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (IsPlaceholder)
|
2020-05-30 01:46:41 +08:00
|
|
|
|
{
|
2020-06-19 23:06:33 +08:00
|
|
|
|
<td style="padding: 0px; border: 0px; height: 0px;"></td>
|
|
|
|
|
}
|
2021-01-09 23:57:31 +08:00
|
|
|
|
else if (IsMeasure)
|
|
|
|
|
{
|
|
|
|
|
<td style="padding: 0px; border: 0px; height: 0px;"><div style="height: 0px; overflow: hidden;"> </div></td>
|
|
|
|
|
}
|
2020-06-19 23:06:33 +08:00
|
|
|
|
else if (IsColGroup)
|
|
|
|
|
{
|
2020-11-09 22:17:27 +08:00
|
|
|
|
if (Width != null)
|
2020-06-19 23:06:33 +08:00
|
|
|
|
{
|
2020-11-09 22:17:27 +08:00
|
|
|
|
<col style="width: @((CssSizeLength)Width); min-width: @((CssSizeLength)Width);">
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
<col />
|
2020-06-19 23:06:33 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-28 16:06:02 +08:00
|
|
|
|
else if (IsHeader && HeaderColSpan != 0)
|
2020-06-19 23:06:33 +08:00
|
|
|
|
{
|
2021-01-10 21:44:25 +08:00
|
|
|
|
<th class="@ClassMapper.Class" style="@FixedStyle @HeaderStyle" @onclick="HandelHeaderClick" colspan="@HeaderColSpan" title="@(Ellipsis?HeaderTitle:"")">
|
2020-07-08 16:12:49 +08:00
|
|
|
|
@if (Sortable)
|
|
|
|
|
{
|
|
|
|
|
if (ShowSorterTooltip)
|
|
|
|
|
{
|
|
|
|
|
@ToolTipSorter(this)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@SortHeader(this)
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-05 18:44:38 +08:00
|
|
|
|
else if (TitleTemplate != null)
|
|
|
|
|
{
|
|
|
|
|
@TitleTemplate
|
|
|
|
|
}
|
2020-07-08 16:12:49 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@HeaderTitle
|
|
|
|
|
}
|
2020-06-05 16:06:23 +08:00
|
|
|
|
</th>
|
2020-05-30 01:46:41 +08:00
|
|
|
|
}
|
2020-11-03 13:31:22 +08:00
|
|
|
|
else if (!IsHeader && RowSpan != 0 && ColSpan != 0)
|
2020-05-30 01:46:41 +08:00
|
|
|
|
{
|
2021-01-10 21:44:25 +08:00
|
|
|
|
|
2021-01-11 22:36:06 +08:00
|
|
|
|
var fieldText = !string.IsNullOrWhiteSpace(Format) ? Formatter<TData>.Format(Field, Format) : Field?.ToString();
|
2021-01-10 21:44:25 +08:00
|
|
|
|
|
2021-01-11 22:36:06 +08:00
|
|
|
|
<td class="@ClassMapper.Class" style="@FixedStyle @Style" rowspan="@RowSpan" colspan="@ColSpan" title="@(Ellipsis? fieldText:"")">
|
2020-11-09 22:17:27 +08:00
|
|
|
|
@if (ColIndex == 1 && Table.TreeMode)
|
|
|
|
|
{
|
2021-01-10 21:44:25 +08:00
|
|
|
|
<span class="ant-table-row-indent indent-level-@RowData.Level" style="padding-left: @((CssSizeLength)(RowData.Level* Table.IndentSize));"></span>
|
2020-11-09 22:17:27 +08:00
|
|
|
|
@if (RowData.HasChildren)
|
|
|
|
|
{
|
2020-12-05 18:44:38 +08:00
|
|
|
|
<button type="button" @onclick="ToggleTreeNode" class="ant-table-row-expand-icon @(RowData?.Expanded==true?"ant-table-row-expand-icon-expanded":"ant-table-row-expand-icon-collapsed")" aria-label="@(RowData?.Expanded==true?Table.Locale.Collapse:Table.Locale.Expand)"></button>
|
2020-11-09 22:17:27 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-12-05 18:44:38 +08:00
|
|
|
|
<button type="button" class="ant-table-row-expand-icon ant-table-row-expand-icon-spaced" aria-label="@Table.Locale.Expand"></button>
|
2020-11-09 22:17:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-05 16:06:23 +08:00
|
|
|
|
@if (CellRender != null)
|
|
|
|
|
{
|
|
|
|
|
@CellRender(Field)
|
|
|
|
|
}
|
|
|
|
|
else if (ChildContent != null)
|
|
|
|
|
{
|
|
|
|
|
@ChildContent
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-07-05 00:09:53 +08:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(Format))
|
|
|
|
|
{
|
|
|
|
|
@(Formatter<TData>.Format(Field,Format))
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@Field
|
|
|
|
|
}
|
2020-06-05 16:06:23 +08:00
|
|
|
|
}
|
|
|
|
|
</td>
|
2020-05-30 01:46:41 +08:00
|
|
|
|
}
|
2020-07-08 16:12:49 +08:00
|
|
|
|
|
|
|
|
|
@code
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string HeaderTitle => Title ?? DisplayName ?? FieldName;
|
|
|
|
|
|
|
|
|
|
readonly RenderFragment<Column<TData>> SortHeader = col =>
|
|
|
|
|
@<div class="ant-table-column-sorters">
|
2020-12-05 18:44:38 +08:00
|
|
|
|
<span>
|
|
|
|
|
@if (col.TitleTemplate != null)@col.TitleTemplate else @col.HeaderTitle
|
|
|
|
|
</span>
|
2020-07-08 16:12:49 +08:00
|
|
|
|
<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>;
|
|
|
|
|
|
2020-09-06 15:31:40 +08:00
|
|
|
|
readonly RenderFragment<Column<TData>> ToolTipSorter = col =>
|
|
|
|
|
@<Tooltip Class="ant-table-column-sorters-with-tooltip" Title="@col.SorterTooltip">
|
|
|
|
|
@col.SortHeader(col)
|
|
|
|
|
</Tooltip>;
|
2020-07-08 16:12:49 +08:00
|
|
|
|
|
2020-12-23 00:47:35 +08:00
|
|
|
|
}
|