feat(module: table): add OnExpand event (#1208)

This commit is contained in:
Andrzej Bakun 2021-03-05 16:58:38 +01:00 committed by ElderJames
parent 16f56f7e9d
commit d1f1227a4f
3 changed files with 18 additions and 1 deletions

View File

@ -191,7 +191,10 @@ namespace AntDesign
private void ToggleTreeNode()
{
bool expandValueBeforeChange = RowData.Expanded;
RowData.Expanded = !RowData.Expanded;
Table?.OnExpandChange(RowData.CacheKey);
if (RowData.Expanded != expandValueBeforeChange)
Table?.Refresh();
}

View File

@ -28,6 +28,8 @@ namespace AntDesign
internal void SelectionChanged();
internal void OnExpandChange(int cacheKey);
internal void Refresh();
internal void ReloadAndInvokeChange();

View File

@ -103,6 +103,9 @@ namespace AntDesign
[Parameter]
public Func<RowData<TItem>, string> ExpandedRowClassName { get; set; } = _ => "";
[Parameter]
public EventCallback<RowData<TItem>> 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;