Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
Introduction="@Localizer["SortableListTableIntro"]"
Name="Table">
<SortableList Option="_optionTable" OnUpdate="OnUpdateTable">
<Table TItem="Foo" Items="@Items" IsStriped="true" ShowLineNo="true">
<Table TItem="Foo" Items="@Items" IsStriped="true" ShowLineNo="true" RenderMode="TableRenderMode.Table">
<TableColumns>
<TableColumn @bind-Field="@context.DateTime" Width="180" />
<TableColumn @bind-Field="@context.Name" />
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.9.1-beta03</Version>
<Version>9.9.1-beta04</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
14 changes: 14 additions & 0 deletions src/BootstrapBlazor/Components/SortableList/ISortableList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone

namespace BootstrapBlazor.Components;

/// <summary>
/// SortableList 组件接口
/// </summary>
public interface ISortableList
{

}
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/Components/Table/Table.razor
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
}
else
{
<DynamicElement class="@GetRowClassString(item, "table-row")" @key="item"
<DynamicElement class="@GetRowClassString(item, "table-row")" @key="GetKeyByITem(item)"
TriggerContextMenu="ContextMenuZone != null" OnContextMenu="e => OnContextMenu(e, item)"
@ontouchstart="e => OnTouchStart(e, item)"
@ontouchend="OnTouchEnd"
Expand Down Expand Up @@ -692,7 +692,7 @@
</thead>;

RenderFragment<TItem> RenderRow => item =>
@<DynamicElement TagName="tr" class="@GetRowClassString(item)" @key="item"
@<DynamicElement TagName="tr" class="@GetRowClassString(item)" @key="GetKeyByITem(item)"
TriggerContextMenu="ContextMenuZone != null" OnContextMenu="e => OnContextMenu(e, item)"
@ontouchstart="e => OnTouchStart(e, item)" @ontouchend="OnTouchEnd"
TriggerClick="@(ClickToSelect || OnClickRowCallback != null)" OnClick="() => ClickRow(item)"
Expand Down
11 changes: 11 additions & 0 deletions src/BootstrapBlazor/Components/Table/Table.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ private string GetSortTooltip(ITableColumn col) => SortName != col.GetFieldName(
[Parameter]
public bool ShowColumnWidthTooltip { get; set; }

///// <summary>
///// 获得/设置 行 Key 回调方法
///// </summary>
//[Parameter]
//public Func<TItem, object?>? OnGetRowKey { get; set; }

private string ScrollWidthString => $"width: {ActualScrollWidth}px;";

private string? GetScrollStyleString(bool condition) => condition
Expand Down Expand Up @@ -780,6 +786,9 @@ public async Task ExpandDetailRow(TItem item)
[CascadingParameter]
private ContextMenuZone? ContextMenuZone { get; set; }

[CascadingParameter]
private ISortableList? SortableList { get; set; }

[Inject]
[NotNull]
private IIconTheme? IconTheme { get; set; }
Expand Down Expand Up @@ -1681,6 +1690,8 @@ private void OnTouchEnd()
TouchStart = false;
}

private object? GetKeyByITem(TItem item) => SortableList != null ? item : null; //OnGetRowKey?.Invoke(item);

/// <summary>
/// Dispose 方法
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions src/BootstrapBlazor/Components/Table/Table.razor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -963,3 +963,7 @@ form .table .table-cell > textarea {
border-bottom-color: var(--bs-primary);
}
}

.bb-sortable tr {
cursor: pointer;
}
Loading