mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-07 14:38:11 +08:00
fix(module: table): perf optimization & data source change issue (#1304)
* chore: add GitHub Actions for auto preview (#1205) * chore: add github actions for auto preview * fix setup job * chore: add GitHub Actions for auto preview (#1205) * fix(module:table): guard against false entries in _dataSourceCache * fix(module:table): perf - double to single render on datasource change * fix(module:table): perf optimization to avoid multiple renders Co-authored-by: James Yeung <shunjiey@hotmail.com>
This commit is contained in:
parent
251a6e18ad
commit
a9a0f2e937
@ -146,6 +146,7 @@ RenderFragment<(Table<TItem> table, IEnumerable<TItem> showItems, int level)> bo
|
|||||||
var table = context.table;
|
var table = context.table;
|
||||||
var showItems = context.showItems;
|
var showItems = context.showItems;
|
||||||
var level = context.level;
|
var level = context.level;
|
||||||
|
var count = Math.Min(showItems.Count(), table._dataSourceCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (table._total <= 0)
|
@if (table._total <= 0)
|
||||||
@ -158,7 +159,7 @@ RenderFragment<(Table<TItem> table, IEnumerable<TItem> showItems, int level)> bo
|
|||||||
}
|
}
|
||||||
else if (showItems != null && table.ColumnContext.Columns.Count > 0)
|
else if (showItems != null && table.ColumnContext.Columns.Count > 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < showItems.Count(); i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
var rowIndex = table.PageSize * (table.PageIndex - 1) + i + 1;
|
var rowIndex = table.PageSize * (table.PageIndex - 1) + i + 1;
|
||||||
var data = showItems.ElementAt(i);
|
var data = showItems.ElementAt(i);
|
||||||
@ -192,7 +193,7 @@ RenderFragment<(Table<TItem> table, IEnumerable<TItem> showItems, int level)> bo
|
|||||||
{
|
{
|
||||||
@table.body((table, table.TreeChildren(data), level + 1));
|
@table.body((table, table.TreeChildren(data), level + 1));
|
||||||
}
|
}
|
||||||
@if (!hasChildren && table.ExpandTemplate != null && table.RowExpandable(currentRowData))
|
@if (!hasChildren && table.ExpandTemplate != null && table.RowExpandable(currentRowData) && currentRowData.Expanded)
|
||||||
{
|
{
|
||||||
<tr class="ant-table-expanded-row ant-table-expanded-row-level-1 @table.ExpandedRowClassName(currentRowData)"
|
<tr class="ant-table-expanded-row ant-table-expanded-row-level-1 @table.ExpandedRowClassName(currentRowData)"
|
||||||
style="@(currentRowData.Expanded?"":"display: none;")">
|
style="@(currentRowData.Expanded?"":"display: none;")">
|
||||||
|
@ -241,7 +241,7 @@ namespace AntDesign
|
|||||||
{
|
{
|
||||||
_treeExpandIconColumnIndex = ExpandIconColumnIndex + (_selection != null && _selection.ColIndex <= ExpandIconColumnIndex ? 1 : 0);
|
_treeExpandIconColumnIndex = ExpandIconColumnIndex + (_selection != null && _selection.ColIndex <= ExpandIconColumnIndex ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
_waitingReload = false;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
return queryModel;
|
return queryModel;
|
||||||
@ -292,19 +292,6 @@ namespace AntDesign
|
|||||||
{
|
{
|
||||||
base.OnAfterRender(firstRender);
|
base.OnAfterRender(firstRender);
|
||||||
|
|
||||||
if (_waitingReloadAndInvokeChange)
|
|
||||||
{
|
|
||||||
_waitingReloadAndInvokeChange = false;
|
|
||||||
_waitingReload = false;
|
|
||||||
|
|
||||||
ReloadAndInvokeChange();
|
|
||||||
}
|
|
||||||
else if (_waitingReload)
|
|
||||||
{
|
|
||||||
_waitingReload = false;
|
|
||||||
Reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!firstRender)
|
if (!firstRender)
|
||||||
{
|
{
|
||||||
this.FinishLoadPage();
|
this.FinishLoadPage();
|
||||||
@ -349,7 +336,22 @@ namespace AntDesign
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool ShouldRender() => this._shouldRender;
|
protected override bool ShouldRender()
|
||||||
|
{
|
||||||
|
if (_waitingReloadAndInvokeChange)
|
||||||
|
{
|
||||||
|
_waitingReloadAndInvokeChange = false;
|
||||||
|
_waitingReload = false;
|
||||||
|
|
||||||
|
ReloadAndInvokeChange();
|
||||||
|
}
|
||||||
|
else if (_waitingReload)
|
||||||
|
{
|
||||||
|
_waitingReload = false;
|
||||||
|
Reload();
|
||||||
|
}
|
||||||
|
return this._shouldRender;
|
||||||
|
}
|
||||||
|
|
||||||
void ITable.HasFixLeft() => _hasFixLeft = true;
|
void ITable.HasFixLeft() => _hasFixLeft = true;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user