mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-02 20:17:58 +08:00
914421651b
* feat(module: list): add event callback for list items * docs: add onitemclick in doc
96 lines
2.9 KiB
C#
96 lines
2.9 KiB
C#
@namespace AntDesign
|
|
@inherits AntDomComponentBase
|
|
@typeparam TItem
|
|
|
|
<div class="@ClassMapper.Class" style="@Style" Id="@Id">
|
|
|
|
@if (Header != null)
|
|
{
|
|
<div class="@PrefixName-header">
|
|
@Header
|
|
</div>
|
|
}
|
|
|
|
@if (DataSource != null && DataSource.Any())
|
|
{
|
|
<Spin Spinning="Loading">
|
|
@childrenContent(this)
|
|
</Spin>
|
|
}
|
|
else
|
|
{
|
|
<div style="min-height:53px" />
|
|
}
|
|
|
|
@if (Footer != null)
|
|
{
|
|
<div class="@PrefixName-footer">
|
|
@Footer
|
|
</div>
|
|
}
|
|
@if (LoadMore != null)
|
|
{
|
|
@LoadMore
|
|
}
|
|
|
|
</div>
|
|
|
|
@code{
|
|
|
|
RenderFragment<AntList<TItem>> childrenContent = content =>
|
|
@<Template>
|
|
|
|
@if (content.Grid != null)
|
|
{
|
|
<Row Gutter="content.Grid.Gutter">
|
|
@foreach (var item in content.DataSource)
|
|
{
|
|
var callback = CallbackFactory.Create(content, () => content.HandleItemClick(item));
|
|
|
|
<CascadingValue Value="callback" Name="ItemClickCallback">
|
|
@if (content.Extra != null)
|
|
{
|
|
<AntListItem ItemCount="content.DataSource.Count()" ItemLayout="content.ItemLayout" Grid="content.Grid" Actions="content.Actions" Extra="content.Extra">
|
|
@content.Item(item)
|
|
</AntListItem>
|
|
}
|
|
else
|
|
{
|
|
<AntListItem ItemCount="content.DataSource.Count()" ItemLayout="content.ItemLayout" Grid="content.Grid" Actions="content.Actions">
|
|
@content.Item(item)
|
|
</AntListItem>
|
|
}
|
|
</CascadingValue>
|
|
}
|
|
</Row>
|
|
}
|
|
else
|
|
{
|
|
<ul class="ant-list-items">
|
|
@foreach (var item in content.DataSource)
|
|
{
|
|
var callback = CallbackFactory.Create(content, () => content.HandleItemClick(item));
|
|
|
|
<CascadingValue Value="callback" Name="ItemClickCallback">
|
|
@if (content.Extra != null)
|
|
{
|
|
<AntListItem ItemCount="content.DataSource.Count()" ItemLayout="content.ItemLayout" Actions="content.Actions" Extra="content.Extra">
|
|
@content.Item(item)
|
|
</AntListItem>
|
|
}
|
|
else
|
|
{
|
|
<AntListItem ItemCount="content.DataSource.Count()" ItemLayout="content.ItemLayout" Actions="content.Actions">
|
|
@content.Item(item)
|
|
</AntListItem>
|
|
}
|
|
</CascadingValue>
|
|
}
|
|
|
|
</ul>
|
|
}
|
|
|
|
</Template>;
|
|
|
|
|
|
} |