mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-05 05:27:37 +08:00
feat(module: table): add OnExpand event (#1208)
This commit is contained in:
parent
16f56f7e9d
commit
d1f1227a4f
@ -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<TData> filter)
|
||||
|
@ -28,6 +28,8 @@ namespace AntDesign
|
||||
|
||||
internal void SelectionChanged();
|
||||
|
||||
internal void OnExpandChange(int cacheKey);
|
||||
|
||||
internal void Refresh();
|
||||
|
||||
internal void ReloadAndInvokeChange();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user