Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1342,11 +1342,6 @@
Gets or sets the index of the Column to act upon
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.ColumnResizeOptions`1.Label">
<summary>
Gets or sets the label to display above the resize options
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.ColumnResizeOptions`1.ResizeType">
<summary>
Gets or sets the type of resize to perform
Expand Down Expand Up @@ -1782,8 +1777,8 @@
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.ResizableColumns">
<summary>
If true, renders draggable handles around the column headers, allowing the user to resize the columns
manually. Size changes are not persisted.
If true, renders draggable handles around the column headers and adds a button to invoke a resize UI.
This allows the user to resize columns manually. Size changes are not persisted.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.ResizeType">
Expand All @@ -1794,6 +1789,11 @@
Exact: resize to the exact width specified (in pixels)
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.ColumnResizeLabels">
<summary>
(Aria) Labels used in the column resize UI.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentDataGrid`1.ItemKey">
<summary>
Optionally defines a value for @key on each rendered row. Typically this should be used to specify a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
GridTemplateColumns="0.2fr 1fr 0.2fr 0.2fr 0.2fr 0.2fr"
RowClass="@rowClass"
RowStyle="@rowStyle"
Style="height: 405px;overflow:auto;">
Style="height: 405px;overflow:auto;"
ColumnResizeLabels="@customLabels">
<TemplateColumn Tooltip="true" TooltipText="@(c => "Flag of " + c.Name)" Title="Rank" SortBy="@rankSort" Align="Align.Center" InitialSortDirection="SortDirection.Ascending" IsDefaultSortColumn=true>
<img class="flag" src="_content/FluentUI.Demo.Shared/flags/@(context.Code).svg" alt="Flag of @(context.Code)" />
</TemplateColumn>
Expand Down Expand Up @@ -63,6 +64,8 @@
int minMedals;
int maxMedals = 130;

ColumnResizeLabels customLabels = new ColumnResizeLabels(DiscreteLabel: "Width (+/- 10px)", ResetAriaLabel: "restore");

GridSort<Country> rankSort = GridSort<Country>
.ByDescending(x => x.Medals.Gold)
.ThenDescending(x => x.Medals.Silver)
Expand Down
4 changes: 2 additions & 2 deletions examples/Demo/Shared/SampleData/DataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private static string GetMonthName(int index)
new Country("bg", "Bulgaria", new Medals { Gold = 3, Silver = 1, Bronze = 3}),
new Country("ca", "Canada", new Medals { Gold = 9, Silver = 7, Bronze = 11}),
new Country("cl", "Chile", new Medals { Gold = 1, Silver = 1, Bronze = 0}),
new Country("cn", "China", new Medals { Gold = 40, Silver = 27, Bronze = 24}),
new Country("cn", "People's Republic of China", new Medals { Gold = 40, Silver = 27, Bronze = 24}),
new Country("ci", "Ivory Coast", new Medals { Gold = 0, Silver = 0, Bronze = 1}),
new Country("co", "Colombia", new Medals { Gold = 0, Silver = 3, Bronze = 1}),
new Country("cv", "Cape Verde", new Medals { Gold = 0, Silver = 0, Bronze = 1}),
Expand Down Expand Up @@ -290,7 +290,7 @@ private static string GetMonthName(int index)
new Country("ch", "Switzerland", new Medals { Gold = 1, Silver = 2, Bronze = 5}),
new Country("th", "Thailand", new Medals { Gold = 1, Silver = 3, Bronze = 2}),
new Country("tj", "Tajikistan", new Medals { Gold = 0, Silver = 0, Bronze = 3}),
new Country("tw", "Chinese Taipei", new Medals { Gold = 2, Silver = 0, Bronze = 5}),
new Country("tpe", "Chinese Taipei", new Medals { Gold = 2, Silver = 0, Bronze = 5}),
new Country("tn", "Tunisia", new Medals { Gold = 1, Silver = 1, Bronze = 1}),
new Country("tr", "Turkey", new Medals { Gold = 0, Silver = 3, Bronze = 5}),
new Country("ug", "Uganda", new Medals { Gold = 1, Silver = 1, Bronze = 0}),
Expand Down
14 changes: 7 additions & 7 deletions src/Core/Components/DataGrid/Columns/ColumnResizeOptions.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<FluentStack Class="resize-options" VerticalAlignment="VerticalAlignment.Center" HorizontalGap="4">
@if (ResizeType == DataGridResizeType.Discrete)
{
<FluentLabel>@Label</FluentLabel>
<FluentLabel>@Grid.ColumnResizeLabels.DiscreteLabel</FluentLabel>

<FluentSpacer />
<FluentButton OnClick="@HandleShrinkAsync" IconStart="@(new CoreIcons.Regular.Size20.Subtract())" />
<FluentButton OnClick="@HandleGrowAsync" IconStart="@(new CoreIcons.Regular.Size20.Add())" />
<FluentButton OnClick="@HandleResetAsync" IconStart="@(new CoreIcons.Regular.Size20.ArrowReset())" />
<FluentButton OnClick="@HandleShrinkAsync" IconStart="@(new CoreIcons.Regular.Size20.Subtract())" aria-label="@(Grid.ColumnResizeLabels.ShrinkAriaLabel)" />
<FluentButton OnClick="@HandleGrowAsync" IconStart="@(new CoreIcons.Regular.Size20.Add())" aria-label="@(Grid.ColumnResizeLabels.GrowAriaLabel)" />
<FluentButton OnClick="@HandleResetAsync" IconStart="@(new CoreIcons.Regular.Size20.ArrowReset())" aria-label="@(Grid.ColumnResizeLabels.ResetAriaLabel)" />
}
else
{
Expand All @@ -22,14 +22,14 @@
InputMode="InputMode.Numeric"
Immediate="true"
ImmediateDelay="200"
Label="@Label"
Label="@Grid.ColumnResizeLabels.ExactLabel"
AutoComplete="off"
@onkeydown="@HandleColumnWidthKeyDownAsync" />
</div>
<FluentButton Style="height: 30px;" OnClick="@HandleColumnWidthAsync" Appearance="@Appearance.Accent">
<FluentButton Style="height: 30px;" OnClick="@HandleColumnWidthAsync" Appearance="@Appearance.Accent" aria-label="@(Grid.ColumnResizeLabels.SubmitAriaLabel)">
<FluentIcon Value="@(new CoreIcons.Regular.Size20.Checkmark())" Color="@Color.Fill" />
</FluentButton>
<FluentButton Style="height: 30px;" OnClick="@HandleResetAsync" IconStart="@(new CoreIcons.Regular.Size20.ArrowReset())" />
<FluentButton Style="height: 30px;" OnClick="@HandleResetAsync" IconStart="@(new CoreIcons.Regular.Size20.ArrowReset())" aria-label="@(Grid.ColumnResizeLabels.ResetAriaLabel)" />
</FluentStack>
}
</FluentStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ public partial class ColumnResizeOptions<TGridItem>
[Parameter]
public int Column { get; set; }

/// <summary>
/// Gets or sets the label to display above the resize options
/// </summary>
[Parameter]
public string? Label{ get; set; }

/// <summary>
/// Gets or sets the type of resize to perform
/// Discrete: resize by a 10 pixels at a time
Expand All @@ -42,8 +36,6 @@ protected override void OnParametersSet()
{
throw new ArgumentException("Column must have a value greater than zero");
}

Label = Grid.ResizeLabel;
}

private async Task HandleShrinkAsync()
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Components/DataGrid/FluentDataGrid.razor
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
<FluentDivider Role="DividerRole.Separator" Style="width: 100%;" />
}

<ColumnResizeOptions Column="@oneBasedIndex" ResizeType=@ResizeType Label="@ResizeLabel" TGridItem="TGridItem" />
<ColumnResizeOptions Column="@oneBasedIndex" ResizeType=@ResizeType TGridItem="TGridItem" />
}

</FluentStack>
Expand Down
9 changes: 6 additions & 3 deletions src/Core/Components/DataGrid/FluentDataGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public partial class FluentDataGrid<TGridItem> : FluentComponentBase, IHandleEve
public float ItemSize { get; set; } = 32;

/// <summary>
/// If true, renders draggable handles around the column headers, allowing the user to resize the columns
/// manually. Size changes are not persisted.
/// If true, renders draggable handles around the column headers and adds a button to invoke a resize UI.
/// This allows the user to resize columns manually. Size changes are not persisted.
/// </summary>
[Parameter]
public bool ResizableColumns { get; set; }
Expand All @@ -100,8 +100,11 @@ public partial class FluentDataGrid<TGridItem> : FluentComponentBase, IHandleEve
[Parameter]
public DataGridResizeType? ResizeType { get; set; }

/// <summary>
/// (Aria) Labels used in the column resize UI.
/// </summary>
[Parameter]
public string ResizeLabel { get; set; } = "Column width (in pixels)";
public ColumnResizeLabels ColumnResizeLabels { get; set; } = new ColumnResizeLabels();

/// <summary>
/// Optionally defines a value for @key on each rendered row. Typically this should be used to specify a
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// ------------------------------------------------------------------------
// MIT License - Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------------------

namespace Microsoft.FluentUI.AspNetCore.Components;

public record ColumnResizeLabels(string DiscreteLabel = "Column width",
string ExactLabel = "Column width (in pixels)",
string GrowAriaLabel = "Grow column width",
string ShrinkAriaLabel = "Shrink column width",
string ResetAriaLabel = "Reset column widths",
string SubmitAriaLabel = "Set column widths");