Skip to content

Commit 423ce90

Browse files
committed
feat: 增加 EmptyTemplate 参数
1 parent 70eae9b commit 423ce90

File tree

2 files changed

+51
-28
lines changed

2 files changed

+51
-28
lines changed

src/BootstrapBlazor/Components/ListView/ListView.razor

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,54 @@
1010
</div>
1111
}
1212
<div class="@BodyClassString">
13-
@if (BodyTemplate != null)
13+
@if (Rows.Count > 0)
1414
{
15-
if (GroupName == null)
15+
if (BodyTemplate != null)
1616
{
17-
foreach (var item in Rows)
17+
if (GroupName == null)
1818
{
19-
<div class="listview-item" @onclick="@(e => OnClick(item))">
20-
@BodyTemplate(item)
21-
</div>
19+
foreach (var item in Rows)
20+
{
21+
<div class="listview-item" @onclick="@(e => OnClick(item))">
22+
@BodyTemplate(item)
23+
</div>
24+
}
2225
}
23-
}
24-
else if (Collapsible)
25-
{
26-
<Collapse IsAccordion="IsAccordion" OnCollapseChanged="OnCollapseChanged!">
27-
<CollapseItems>
28-
@RenderCollapsibleItems(GroupName)
29-
</CollapseItems>
30-
</Collapse>
31-
}
32-
else
33-
{
34-
foreach (var key in GetGroupItems(GroupName))
26+
else if (Collapsible)
3527
{
36-
<div @key="@key.GroupName" class="accordion-item">
37-
<div class="accordion-header">@key.GroupName</div>
38-
<div class="accordion-body">
39-
@foreach (var item in key.Items)
40-
{
41-
<div class="listview-item" @onclick="@(e => OnClick(item))">
42-
@BodyTemplate(item)
43-
</div>
44-
}
28+
<Collapse IsAccordion="IsAccordion" OnCollapseChanged="OnCollapseChanged!">
29+
<CollapseItems>
30+
@RenderCollapsibleItems(GroupName)
31+
</CollapseItems>
32+
</Collapse>
33+
}
34+
else
35+
{
36+
foreach (var key in GetGroupItems(GroupName))
37+
{
38+
<div @key="@key.GroupName" class="accordion-item">
39+
<div class="accordion-header">@key.GroupName</div>
40+
<div class="accordion-body">
41+
@foreach (var item in key.Items)
42+
{
43+
<div class="listview-item" @onclick="@(e => OnClick(item))">
44+
@BodyTemplate(item)
45+
</div>
46+
}
47+
</div>
4548
</div>
46-
</div>
49+
}
4750
}
4851
}
4952
}
53+
else if (EmptyTemplate != null)
54+
{
55+
@EmptyTemplate
56+
}
57+
else
58+
{
59+
@EmptyText
60+
}
5061
</div>
5162
@if (FooterTemplate != null || Pageable)
5263
{

src/BootstrapBlazor/Components/ListView/ListView.razor.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,18 @@ public partial class ListView<TItem> : BootstrapComponentBase
128128
[Parameter]
129129
public string? Height { get; set; }
130130

131+
/// <summary>
132+
/// 获得/设置 无数据时模板 默认 null 未设置
133+
/// </summary>
134+
[Parameter]
135+
public RenderFragment? EmptyTemplate { get; set; }
136+
137+
/// <summary>
138+
/// 获得/设置 无数据时显示文字 默认 null 未设置使用资源文件设置文字
139+
/// </summary>
140+
[Parameter]
141+
public string? EmptyText { get; set; }
142+
131143
/// <summary>
132144
/// 获得/设置 当前页码
133145
/// </summary>

0 commit comments

Comments
 (0)