From b4345746859c105666c3284006de94cc9c7a7261 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Mon, 7 Oct 2024 18:02:04 +0200 Subject: [PATCH] [DataGrid] Add `HeaderTootip` to columns to allow for custom header tooltip text (#2775) * Fix #2757 by using TooltipText if set (instead of always using Title) * Add HeaderTooltip --- .../Shared/Microsoft.FluentUI.AspNetCore.Components.xml | 7 ++++++- .../Shared/Pages/DataGrid/Examples/DataGridTypical.razor | 2 +- src/Core/Components/DataGrid/Columns/ColumnBase.razor | 4 ++-- src/Core/Components/DataGrid/Columns/ColumnBase.razor.cs | 8 +++++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml b/examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml index 3ce340929a..0407df2a43 100644 --- a/examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml +++ b/examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml @@ -1204,7 +1204,12 @@ - Gets or sets the value to be used as the tooltip and aria-label in this column's cells + Gets or sets the function that defines the value to be used as the tooltip and aria-label in this column's cells + + + + + Gets or sets the tooltip text for the column header. diff --git a/examples/Demo/Shared/Pages/DataGrid/Examples/DataGridTypical.razor b/examples/Demo/Shared/Pages/DataGrid/Examples/DataGridTypical.razor index c3a7fd6db0..84195fa744 100644 --- a/examples/Demo/Shared/Pages/DataGrid/Examples/DataGridTypical.razor +++ b/examples/Demo/Shared/Pages/DataGrid/Examples/DataGridTypical.razor @@ -14,7 +14,7 @@ HeaderCellAsButtonWithMenu="true" Style="height: 405px;overflow:auto;" ColumnResizeLabels="@customLabels"> - + Flag of @(context.Code) diff --git a/src/Core/Components/DataGrid/Columns/ColumnBase.razor b/src/Core/Components/DataGrid/Columns/ColumnBase.razor index 9d7475b32a..a9e18748bc 100644 --- a/src/Core/Components/DataGrid/Columns/ColumnBase.razor +++ b/src/Core/Components/DataGrid/Columns/ColumnBase.razor @@ -15,7 +15,7 @@ } else if (Grid.HeaderCellAsButtonWithMenu) { - string? tooltip = Tooltip ? Title : null; + string? tooltip = Tooltip ? (HeaderTooltip ?? Title) : null; @@ -62,7 +62,7 @@ } else { - string? tooltip = Tooltip ? Title : null; + string? tooltip = Tooltip ? (HeaderTooltip ?? Title) : null; @if (Align == Align.Start || Align == Align.Center) { diff --git a/src/Core/Components/DataGrid/Columns/ColumnBase.razor.cs b/src/Core/Components/DataGrid/Columns/ColumnBase.razor.cs index f186b6ac45..def61a9c7d 100644 --- a/src/Core/Components/DataGrid/Columns/ColumnBase.razor.cs +++ b/src/Core/Components/DataGrid/Columns/ColumnBase.razor.cs @@ -55,11 +55,17 @@ public abstract partial class ColumnBase public bool Tooltip { get; set; } = false; /// - /// Gets or sets the value to be used as the tooltip and aria-label in this column's cells + /// Gets or sets the function that defines the value to be used as the tooltip and aria-label in this column's cells /// [Parameter] public Func? TooltipText { get; set; } + /// + /// Gets or sets the tooltip text for the column header. + /// + [Parameter] + public string? HeaderTooltip { get; set; } + /// /// Gets or sets an optional template for this column's header cell. /// If not specified, the default header template includes the along with any applicable sort indicators and options buttons.