diff --git a/components/table/ActionColumn.razor b/components/table/ActionColumn.razor index 91885848..e65a1354 100644 --- a/components/table/ActionColumn.razor +++ b/components/table/ActionColumn.razor @@ -57,7 +57,7 @@ else if (!IsHeader && RowSpan != 0 && ColSpan != 0) @if (AppendExpandColumn) { - @if (Table.RowExpandable(RowData) && (!Table.TreeMode || !RowData.HasChildren)) + @if (Table.RowExpandable(RowData) && (!Table.TreeMode || !DataItem.HasChildren)) { } diff --git a/components/table/Column.razor b/components/table/Column.razor index 6225e899..e05406b4 100644 --- a/components/table/Column.razor +++ b/components/table/Column.razor @@ -68,7 +68,7 @@ else if (IsBody && RowSpan != 0 && ColSpan != 0) @if (AppendExpandColumn) { - @if (Table.RowExpandable(RowData) && (!Table.TreeMode || !RowData.HasChildren)) + @if (Table.RowExpandable(RowData) && (!Table.TreeMode || !DataItem.HasChildren)) { - } - else - { - - } - } + { + + @if (DataItem.HasChildren) + { + + } + else + { + + } + } @if (IsFiexedEllipsis) { diff --git a/components/table/ColumnBase.cs b/components/table/ColumnBase.cs index ff09f2d8..d1a4ba01 100644 --- a/components/table/ColumnBase.cs +++ b/components/table/ColumnBase.cs @@ -32,6 +32,8 @@ namespace AntDesign [CascadingParameter(Name = "RowData")] public RowData RowData { get; set; } + protected TableDataItem DataItem => RowData.TableDataItem; + [CascadingParameter(Name = "IsMeasure")] public bool IsMeasure { get; set; } diff --git a/components/table/ITable.cs b/components/table/ITable.cs index 3af2c211..fbf7e828 100644 --- a/components/table/ITable.cs +++ b/components/table/ITable.cs @@ -15,7 +15,7 @@ namespace AntDesign QueryModel GetQueryModel(); - void SetSelection(string[] keys); + void SetSelection(ICollection keys); void SelectAll(); @@ -43,6 +43,8 @@ namespace AntDesign internal SortDirection[] SortDirections { get; } + internal void SetSelection(ISelectionColumn selectItem); + internal bool AllSelected { get; } internal bool AnySelected { get; } diff --git a/components/table/PropertyColumn.cs b/components/table/PropertyColumn.cs index e6332b5f..d4f0eb13 100644 --- a/components/table/PropertyColumn.cs +++ b/components/table/PropertyColumn.cs @@ -29,7 +29,7 @@ namespace AntDesign else if (IsBody) { var compliedProperty = Property.Compile(); - GetValue = rowData => compliedProperty.Invoke(((RowData)rowData).Data); + GetValue = rowData => compliedProperty.Invoke(((RowData)rowData).DataItem.Data); } base.OnInitialized(); } diff --git a/components/table/Selection.razor.cs b/components/table/Selection.razor.cs index 7857fdc0..917fd31b 100644 --- a/components/table/Selection.razor.cs +++ b/components/table/Selection.razor.cs @@ -22,8 +22,8 @@ namespace AntDesign //private bool _checked; private bool Indeterminate => IsHeader - && !Table.AllSelected - && Table.AnySelected; + && Table.AnySelected + && !Table.AllSelected; public IList RowSelections { get; set; } = new List(); @@ -50,12 +50,11 @@ namespace AntDesign { if (Type == "radio") { - Table.SetSelection(new[] { Key }); + Table.SetSelection(this); } else { - RowData.Selected = selected; - Table.Selection.StateHasChanged(); + DataItem.Selected = selected; } } } @@ -87,10 +86,10 @@ namespace AntDesign // avoid check the disabled one but allow default checked if (Disabled && _selected.HasValue) { - RowData.SetSelected(_selected.Value); + DataItem.SetSelected(_selected.Value); } - _selected = RowData.Selected; + _selected = DataItem.Selected; } void ISelectionColumn.StateHasChanged() diff --git a/components/table/Table.razor b/components/table/Table.razor index 8f0a9ecb..fec47684 100644 --- a/components/table/Table.razor +++ b/components/table/Table.razor @@ -56,7 +56,7 @@ @ChildContent(_fieldModel) - @body(this, _showItems, 0, _dataSourceCache) + @body(this, _showItems, 0, _rootRowDataCache) @tfoot(this) @@ -74,7 +74,7 @@ @ChildContent(_fieldModel) - @body(this, _showItems, 0, _dataSourceCache) + @body(this, _showItems, 0, _rootRowDataCache) @tfoot(this) @@ -87,7 +87,7 @@ @colGroup((this, true)) @header(this) - @body(this, _showItems, 0, _dataSourceCache) + @body(this, _showItems, 0, _rootRowDataCache) @tfoot(this) @@ -169,7 +169,7 @@ RenderFragment<(Table table, bool header)> colGroup = ctx => ; - RenderFragment body(Table table, IEnumerable showItems, int level, Dictionary> rowDataCache) => + RenderFragment body(Table table, IEnumerable showItems, int level, IDictionary> rowDataCache) => @