ant-design-blazor/components/table/Table.razor
James Yeung 63d09f76a5 feat(module: table): add selection (#190)
* feat: add pagination and empty

* fix: indent

* feat(module: table): add checkbox selection

* feat(module: table): add radio selection

* feat: add selected rows
2020-06-05 16:06:23 +08:00

71 lines
3.3 KiB
C#

@namespace AntDesign
@inherits AntDomComponentBase
@typeparam TItem
<div class="ant-table-wrapper">
<Spin Spinning="Loading">
@if (ShowPagination && PaginationPosition.Contains("top"))
{
<Pagination Class="@PaginationClass"
Total="Total"
PageSize="PageSize"
Current="PageIndex"
OnPageIndexChange="HandlePageIndexChange"
OnPageSizeChange="HandlePageSizeChange" />
}
<CascadingValue Value="@this" TValue="ITable">
<div class="ant-table">
<div class="ant-table-container">
<div class="ant-table-content">
<table style="table-layout: auto;">
<colgroup></colgroup>
<thead class="ant-table-thead">
<tr>
<CascadingValue Name="IsHeader" Value="true">
@if (_fieldModel != null)
{
@ChildContent(_fieldModel)
}
</CascadingValue>
</tr>
</thead>
<tbody class="ant-table-tbody">
@if (ActualTotal <= 0)
{
<tr class="ant-table-placeholder">
<td colspan="6" class="ant-table-cell">
<Empty Simple />
</td>
</tr>
}
else if (ShowItems != null && _columns.Count > 0)
{
for (int i = 0; i < ShowItems.Count(); i++)
{
var data = ShowItems.ElementAt(i);
var @checked = HeaderSelection?.RowSelections.ElementAtOrDefault(i)?.Checked??false;
<CascadingValue Value="i" Name="Index">
<tr class="ant-table-row ant-table-row-level-0 @(@checked ? "ant-table-row-selected" : "")">
@ChildContent(data)
</tr>
</CascadingValue>
}
}
</tbody>
</table>
</div>
</div>
</div>
</CascadingValue>
@if (ShowPagination && PaginationPosition.Contains("bottom"))
{
<Pagination Class="@PaginationClass"
Total="Total"
PageSize="PageSize"
Current="PageIndex"
OnPageIndexChange="HandlePageIndexChange"
OnPageSizeChange="HandlePageSizeChange" />
}
</Spin>
</div>