!3595 feat(#I64VRE): update fixed column logic for table component

* chore: bump version 7.1.4-beta02
* feat: 增加固定列缓存
* chore: bump version 7.1.4-beta01
This commit is contained in:
Argo 2022-12-08 06:11:22 +00:00
parent 60dd3523f2
commit dd7a917ee0
3 changed files with 15 additions and 5 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<Version>7.1.3</Version>
<Version>7.1.4-beta02</Version>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">

View File

@ -2,6 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
using System.Collections.Concurrent;
namespace BootstrapBlazor.Components;
/// <summary>
@ -159,7 +161,9 @@ public partial class Table<TItem>
private bool IsLastMultiColumn() => FixedMultipleColumn && (!FixedExtendButtonsColumn || !IsExtendButtonsInRowHeader) && !GetColumns().Any(i => i.Fixed);
private bool IsLastColumn(ITableColumn col)
private ConcurrentDictionary<ITableColumn, bool> LastFixedColumnCache { get; } = new();
private bool IsLastColumn(ITableColumn col) => LastFixedColumnCache.GetOrAdd(col, col =>
{
var ret = false;
if (col.Fixed && !IsTail(col))
@ -168,11 +172,13 @@ public partial class Table<TItem>
ret = index < Columns.Count && Columns[index].Fixed == false;
}
return ret;
}
});
private bool IsLastExtendButtonColumn() => IsExtendButtonsInRowHeader && !GetColumns().Any(i => i.Fixed);
private bool IsFirstColumn(ITableColumn col)
private ConcurrentDictionary<ITableColumn, bool> FirstFixedColumnCache { get; } = new();
private bool IsFirstColumn(ITableColumn col) => FirstFixedColumnCache.GetOrAdd(col, col =>
{
var ret = false;
if (col.Fixed && IsTail(col))
@ -181,7 +187,7 @@ public partial class Table<TItem>
ret = index > 0 && Columns[index].Fixed == false;
}
return ret;
}
});
private bool IsFirstExtendButtonColumn() => !IsExtendButtonsInRowHeader && !GetColumns().Any(i => i.Fixed);

View File

@ -773,6 +773,10 @@ public partial class Table<TItem>
Columns.Clear();
Columns.AddRange(cols);
// Columns 重构 清空缓存
FirstFixedColumnCache.Clear();
LastFixedColumnCache.Clear();
InternalResetVisibleColumns(Columns.Select(i => new ColumnVisibleItem(i.GetFieldName(), i.Visible)));
QueryDynamicItems(DynamicContext);