diff --git a/components/table/Column.razor.cs b/components/table/Column.razor.cs index b72d9a36..4cc7a659 100644 --- a/components/table/Column.razor.cs +++ b/components/table/Column.razor.cs @@ -191,8 +191,11 @@ namespace AntDesign private void ToggleTreeNode() { + bool expandValueBeforeChange = RowData.Expanded; RowData.Expanded = !RowData.Expanded; - Table?.Refresh(); + Table?.OnExpandChange(RowData.CacheKey); + if (RowData.Expanded != expandValueBeforeChange) + Table?.Refresh(); } private void FilterSelected(TableFilter filter) diff --git a/components/table/ITable.cs b/components/table/ITable.cs index 2e8ac321..154c6e0a 100644 --- a/components/table/ITable.cs +++ b/components/table/ITable.cs @@ -28,6 +28,8 @@ namespace AntDesign internal void SelectionChanged(); + internal void OnExpandChange(int cacheKey); + internal void Refresh(); internal void ReloadAndInvokeChange(); diff --git a/components/table/Table.razor.cs b/components/table/Table.razor.cs index f23d1bb2..8e384572 100644 --- a/components/table/Table.razor.cs +++ b/components/table/Table.razor.cs @@ -103,6 +103,9 @@ namespace AntDesign [Parameter] public Func, string> ExpandedRowClassName { get; set; } = _ => ""; + [Parameter] + public EventCallback> OnExpand { get; set; } + [Parameter] public SortDirection[] SortDirections { get; set; } = SortDirection.Preset.Default; @@ -145,8 +148,17 @@ namespace AntDesign int ITable.ExpandIconColumnIndex => ExpandIconColumnIndex; int ITable.TreeExpandIconColumnIndex => _treeExpandIconColumnIndex; bool ITable.HasExpandTemplate => ExpandTemplate != null; + SortDirection[] ITable.SortDirections => SortDirections; + void ITable.OnExpandChange(int cacheKey) + { + if (OnExpand.HasDelegate && _dataSourceCache.TryGetValue(cacheKey, out var currentRowData)) + { + OnExpand.InvokeAsync(currentRowData); + } + } + public void ReloadData() { PageIndex = 1;