mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-01 19:50:31 +08:00
perf(Table): improve performance for select all on header (#4740)
This commit is contained in:
parent
8308fb4f69
commit
541eadb6a6
@ -42,13 +42,13 @@ public partial class Table<TItem>
|
||||
var filterRows = ShowRowCheckboxCallback == null ? Rows : Rows.Where(ShowRowCheckboxCallback);
|
||||
if (filterRows.Any())
|
||||
{
|
||||
if (filterRows.All(AnyRow))
|
||||
if (!filterRows.Except(SelectedRows).Any())
|
||||
{
|
||||
// 所有行被选中
|
||||
// all rows are selected
|
||||
ret = CheckboxState.Checked;
|
||||
}
|
||||
else if (filterRows.Any(AnyRow))
|
||||
else if (filterRows.Any(row => SelectedRows.Any(i => Equals(i, row))))
|
||||
{
|
||||
// 任意一行被选中
|
||||
// any one row is selected
|
||||
@ -56,8 +56,6 @@ public partial class Table<TItem>
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
bool AnyRow(TItem row) => SelectedRows.Any(i => Equals(i, row));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -104,7 +102,7 @@ public partial class Table<TItem>
|
||||
/// <param name="val"></param>
|
||||
protected virtual async Task OnHeaderCheck(CheckboxState state, TItem val)
|
||||
{
|
||||
SelectedRows.RemoveAll(x => Rows.Any(a => Equals(a, x)));
|
||||
SelectedRows.RemoveAll(Rows.Intersect(SelectedRows).Contains);
|
||||
if (state == CheckboxState.Checked)
|
||||
{
|
||||
SelectedRows.AddRange(ShowRowCheckboxCallback == null ? Rows : Rows.Where(ShowRowCheckboxCallback));
|
||||
|
Loading…
Reference in New Issue
Block a user