mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-04 04:59:38 +08:00
!3764 feat(#I6ALST): add CollapsedGroupCallback parameter on ListView
* chore: bump version 7.2.4-beta01 * doc: 增加 CollapsedGroupCallback 参数说明文档 * refactor: 重命名回调方法 * doc: 更新资源文件 * doc: 精简示例 * refactor: 增加默认展开第一个分组项目逻辑 * doc: 更新示例文档 * feat: 增加 CollapsedGroupCallbackFirstRender 回调 * doc: 更新注释文档
This commit is contained in:
parent
583c3fc192
commit
b035872db6
@ -4253,7 +4253,8 @@
|
||||
"IsAccordion": "Group accordion",
|
||||
"OnQueryAsync": "Asynchronous query callback method",
|
||||
"OnListViewItemClick": "The ListView element calls back when it clicks on the delegate",
|
||||
"QueryAsync": "Manually query data methods"
|
||||
"QueryAsync": "Manually query data methods",
|
||||
"CollapsedGroupCallback": "Callback for set the IsCollapsed parameter of Collapse component"
|
||||
},
|
||||
"BootstrapBlazor.Shared.Samples.Locators": {
|
||||
"Title": "Get the IP geographic location",
|
||||
|
@ -4260,7 +4260,8 @@
|
||||
"IsAccordion": "分组数据手风琴效果",
|
||||
"OnQueryAsync": "异步查询回调方法",
|
||||
"OnListViewItemClick": "ListView元素点击时回调委托",
|
||||
"QueryAsync": "手工查询数据方法"
|
||||
"QueryAsync": "手工查询数据方法",
|
||||
"CollapsedGroupCallback": "组件分组项是否收缩回调委托方法"
|
||||
},
|
||||
"BootstrapBlazor.Shared.Samples.Locators": {
|
||||
"Title": "获取 IP 地理位置",
|
||||
|
@ -69,7 +69,7 @@
|
||||
|
||||
<DemoBlock Title="@Localizer["CollapsableTitle"]" Introduction="@Localizer["CollapsableIntro"]" Name="Collapsable">
|
||||
<div class="listview-demo">
|
||||
<ListView TItem="Product" GroupName="@(p => p.Category)" OnQueryAsync="@OnQueryAsync" Collapsable="true">
|
||||
<ListView TItem="Product" GroupName="@(p => p.Category)" OnQueryAsync="@OnQueryAsync" Collapsable="true" CollapsedGroupCallback="CollapsedGroupCallback">
|
||||
<HeaderTemplate>
|
||||
<div>@Localizer["ProductListText"]</div>
|
||||
</HeaderTemplate>
|
||||
|
@ -46,6 +46,8 @@ public sealed partial class ListViews
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private static bool CollapsedGroupCallback(object? groupKey) => groupKey?.ToString() != "Group1";
|
||||
|
||||
private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
|
||||
{
|
||||
new AttributeItem(){
|
||||
@ -110,6 +112,13 @@ public sealed partial class ListViews
|
||||
Type = "Func<TItem, Task>",
|
||||
ValueList = " — ",
|
||||
DefaultValue = " — "
|
||||
},
|
||||
new AttributeItem() {
|
||||
Name = nameof(ListView<Foo>.CollapsedGroupCallback),
|
||||
Description = Localizer["CollapsedGroupCallback"],
|
||||
Type = "Func<object?, bool>",
|
||||
ValueList = " — ",
|
||||
DefaultValue = " — "
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>7.2.3</Version>
|
||||
<Version>7.2.4-beta01</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
|
||||
|
@ -16,7 +16,7 @@ public class CollapseItem : BootstrapComponentBase, IDisposable
|
||||
public string? Text { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 当前状态是否激活
|
||||
/// 获得/设置 当前状态是否激活 默认 true
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public bool IsCollapsed { get; set; } = true;
|
||||
|
@ -25,16 +25,19 @@
|
||||
{
|
||||
<Collapse IsAccordion="IsAccordion" OnCollapseChanged="OnCollapseChanged!">
|
||||
<CollapseItems>
|
||||
@foreach (var key in Rows.GroupBy(GroupName).OrderBy(k => k.Key))
|
||||
{
|
||||
<CollapseItem @key="@key.Key" Text="@key.Key?.ToString()">
|
||||
@foreach (var item in key)
|
||||
{
|
||||
<div class="listview-item" @onclick="@(e => OnClick(item))">
|
||||
@BodyTemplate.Invoke(item)
|
||||
</div>
|
||||
}
|
||||
</CollapseItem>
|
||||
@{
|
||||
var index = 0;
|
||||
foreach (var key in Rows.GroupBy(GroupName).OrderBy(k => k.Key))
|
||||
{
|
||||
<CollapseItem @key="@key.Key" Text="@key.Key?.ToString()" IsCollapsed="IsCollapsed(index++, key.Key)">
|
||||
@foreach (var item in key)
|
||||
{
|
||||
<div class="listview-item" @onclick="@(e => OnClick(item))">
|
||||
@BodyTemplate.Invoke(item)
|
||||
</div>
|
||||
}
|
||||
</CollapseItem>
|
||||
}
|
||||
}
|
||||
</CollapseItems>
|
||||
</Collapse>
|
||||
|
@ -75,6 +75,12 @@ public partial class ListView<TItem> : BootstrapComponentBase
|
||||
[Parameter]
|
||||
public Func<CollapseItem, Task>? OnCollapseChanged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 首次渲染是否收缩回调委托
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public Func<object?, bool>? CollapsedGroupCallback { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 异步查询回调方法
|
||||
/// </summary>
|
||||
@ -125,6 +131,8 @@ public partial class ListView<TItem> : BootstrapComponentBase
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsCollapsed(int index, object? groupKey) => CollapsedGroupCallback?.Invoke(groupKey) ?? index > 0;
|
||||
|
||||
/// <summary>
|
||||
/// 点击页码调用此方法
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user