-
Notifications
You must be signed in to change notification settings - Fork 468
Simplify pinned-column wording, preserve demo page metadata, and remove tracked generated props file #4673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify pinned-column wording, preserve demo page metadata, and remove tracked generated props file #4673
Changes from 5 commits
274b393
23b3c4f
c76e2cb
1b4c295
6e4243d
a0f46eb
b2175fe
2403bfd
c0b87b3
41021db
e7575ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -424,3 +424,4 @@ all-icons.json | |
| all-emojis.json | ||
| /global.json | ||
| /src/Core.Scripts/src/BuildConstants.ts | ||
| /src/Core.Scripts/obj/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,8 @@ | ||
| --- | ||
| title: Pinned columns | ||
| order: 0095 | ||
| route: /DataGrid/PinnedColumns | ||
| --- | ||
|
|
||
| # Pinned columns | ||
|
|
||
| Columns can be pinned (frozen) to the left or right edge of the grid so that they remain visible | ||
| while the user scrolls horizontally through wider datasets. | ||
| Columns can be pinned (frozen) to the start or end edge of the grid so that they remain visible | ||
| while the user scrolls horizontally through wider datasets. Using `Start`/`End` instead of | ||
| `Left`/`Right` means pinned columns automatically work correctly in both LTR and RTL layouts. | ||
|
|
||
| ## Parameters | ||
|
|
||
|
|
@@ -16,18 +11,18 @@ Set the `Pin` parameter on any `PropertyColumn` or `TemplateColumn`: | |
| | Value | Behavior | | ||
| |---|---| | ||
| | `DataGridColumnPin.None` | Default — column scrolls normally | | ||
| | `DataGridColumnPin.Left` | Column stays anchored to the left edge | | ||
| | `DataGridColumnPin.Right` | Column stays anchored to the right edge | | ||
| | `DataGridColumnPin.Start` | Column stays anchored to the start edge (left in LTR, right in RTL) | | ||
| | `DataGridColumnPin.End` | Column stays anchored to the end edge (right in LTR, left in RTL) | | ||
|
|
||
| ## Rules | ||
|
|
||
| * **Explicit pixel width required.** Every pinned column must declare a `Width` in pixels | ||
| (e.g. `Width="150px"`). Relative units (`fr`, `%`) are not supported because the browser cannot | ||
| determine a fixed sticky offset from them at render time. | ||
| * **Left-pinned columns must be contiguous at the start.** Each left-pinned column must | ||
| immediately follow another left-pinned column, or be the very first column. | ||
| * **Right-pinned columns must be contiguous at the end.** Each right-pinned column must | ||
| immediately precede another right-pinned column, or be the very last column. | ||
| * **Start-pinned columns must be contiguous at the start.** Each start-pinned column must | ||
| immediately follow another start-pinned column, or be the very first column. | ||
| * **End-pinned columns must be contiguous at the end.** Each end-pinned column must | ||
| immediately precede another end-pinned column, or be the very last column. | ||
| * Violating any of these rules throws an `ArgumentException` with a descriptive message. | ||
|
|
||
| ## Scrollable container | ||
|
|
@@ -39,10 +34,10 @@ bar appears when columns overflow the container: | |
| ```razor | ||
| <div style="overflow-x: auto;"> | ||
| <FluentDataGrid Items="@employees" Style="min-width: max-content;"> | ||
| <PropertyColumn Title="ID" Property="@(e => e.Id)" Width="60px" Pin="DataGridColumnPin.Left" /> | ||
| <PropertyColumn Title="Name" Property="@(e => e.Name)" Width="160px" Pin="DataGridColumnPin.Left" /> | ||
| <PropertyColumn Title="ID" Property="@(e => e.Id)" Width="60px" Pin="DataGridColumnPin.Start" /> | ||
| <PropertyColumn Title="Name" Property="@(e => e.Name)" Width="160px" Pin="DataGridColumnPin.Start" /> | ||
| <PropertyColumn Title="City" Property="@(e => e.City)" /> | ||
| <TemplateColumn Title="Actions" Width="120px" Pin="DataGridColumnPin.Right"> | ||
| <TemplateColumn Title="Actions" Width="120px" Pin="DataGridColumnPin.End"> | ||
| ... | ||
| </TemplateColumn> | ||
| </FluentDataGrid> | ||
|
|
@@ -64,16 +59,16 @@ property `--fluent-data-grid-pinned-background`: | |
| ## Notes | ||
|
|
||
| * Column resizing interacts correctly with sticky offsets — the JavaScript in | ||
| `FluentDataGrid.razor.ts` recalculates `left` / `right` values after every resize step via | ||
| `FluentDataGrid.razor.ts` recalculates start and end offset values after every resize step via | ||
|
||
| `UpdatePinnedColumnOffsets`. | ||
| * Virtualization and paging are fully compatible because each rendered row's cells carry the | ||
| same `position: sticky` styling regardless of which page or scroll position is active. | ||
| * In RTL layouts the browser interprets `left` / `right` according to the document direction, so | ||
| pinned columns behave correctly without additional configuration. | ||
| * RTL layouts are fully supported: start and end automatically map to the correct physical | ||
| direction based on the document's writing mode. | ||
|
|
||
| ## Example | ||
|
|
||
| Demonstrates pinned (frozen) columns using `Pin="DataGridColumnPin.Left"` and `Pin="DataGridColumnPin.Right"`. | ||
| Demonstrates pinned (frozen) columns using `Pin="DataGridColumnPin.Start"` and `Pin="DataGridColumnPin.End"`. | ||
| The two leftmost columns and the Actions column remain visible while the rest scroll horizontally. | ||
|
|
||
| Wrap the grid in a `<div style="overflow-x: auto;">` container and give the grid a `Style="min-width: max-content;"` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -564,10 +564,10 @@ export namespace Microsoft.FluentUI.Blazor.DataGrid { | |
| * pinned column so that columns stack correctly against the grid edge after the initial | ||
| * render or after a column is resized. | ||
| * | ||
|
Comment on lines
562
to
566
|
||
| * Left-pinned columns are processed left-to-right; each column's offset is the sum of | ||
| * the widths of all left-pinned columns to its left. | ||
| * Right-pinned columns are processed right-to-left; each column's offset is the sum of | ||
| * the widths of all right-pinned columns to its right. | ||
| * Start-pinned columns are processed in DOM order; each column's offset is the sum of | ||
| * the widths of all start-pinned columns before it. | ||
| * End-pinned columns are processed in reverse DOM order; each column's offset is the sum of | ||
| * the widths of all end-pinned columns after it. | ||
| * | ||
| * The function reads the actual rendered header-cell width so it handles both Grid mode | ||
| * (CSS grid layout) and Table mode (standard table layout). Grid mode uses `offsetWidth` | ||
|
|
@@ -592,7 +592,7 @@ export namespace Microsoft.FluentUI.Blazor.DataGrid { | |
| * Applies a cumulative sticky offset to all cells in a column and returns the new | ||
| * running total to be used by the next column in the sequence. | ||
| */ | ||
| function applyOffset(header: HTMLElement, offset: number, side: 'left' | 'right'): number { | ||
| function applyOffset(header: HTMLElement, offset: number, side: 'insetInlineStart' | 'insetInlineEnd'): number { | ||
| const colIndex = header.getAttribute('col-index'); | ||
| if (!colIndex) { return offset; } | ||
|
|
||
|
|
@@ -602,24 +602,24 @@ export namespace Microsoft.FluentUI.Blazor.DataGrid { | |
| return offset + headerWidth(header); | ||
| } | ||
|
|
||
| // Left-pinned columns: process in DOM (left-to-right) order. | ||
| const leftPinnedHeaders = Array.from( | ||
| gridElement.querySelectorAll('th.col-pinned-left') | ||
| // Start-pinned columns: process in DOM order. | ||
| const startPinnedHeaders = Array.from( | ||
| gridElement.querySelectorAll('th.col-pinned-start') | ||
| ) as HTMLElement[]; | ||
|
|
||
| let leftOffset = 0; | ||
| for (const header of leftPinnedHeaders) { | ||
| leftOffset = applyOffset(header, leftOffset, 'left'); | ||
| let startOffset = 0; | ||
| for (const header of startPinnedHeaders) { | ||
| startOffset = applyOffset(header, startOffset, 'insetInlineStart'); | ||
| } | ||
|
|
||
| // Right-pinned columns: process in reverse DOM (right-to-left) order. | ||
| const rightPinnedHeaders = Array.from( | ||
| gridElement.querySelectorAll('th.col-pinned-right') | ||
| // End-pinned columns: process in reverse DOM order. | ||
| const endPinnedHeaders = Array.from( | ||
| gridElement.querySelectorAll('th.col-pinned-end') | ||
| ) as HTMLElement[]; | ||
|
|
||
| let rightOffset = 0; | ||
| for (let i = rightPinnedHeaders.length - 1; i >= 0; i--) { | ||
| rightOffset = applyOffset(rightPinnedHeaders[i], rightOffset, 'right'); | ||
| let endOffset = 0; | ||
| for (let i = endPinnedHeaders.length - 1; i >= 0; i--) { | ||
| endOffset = applyOffset(endPinnedHeaders[i], endOffset, 'insetInlineEnd'); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,8 +31,8 @@ public FluentDataGridCell(LibraryConfiguration configuration) : base(configurati | |||||||||||||
| .AddClass("column-header", when: CellType == DataGridCellType.ColumnHeader) | ||||||||||||||
| .AddClass("select-all", when: CellType == DataGridCellType.ColumnHeader && Column is SelectColumn<TGridItem>) | ||||||||||||||
| .AddClass("multiline-text", when: Grid.MultiLine && (Grid.Items is not null || Grid.ItemsProvider is not null) && CellType != DataGridCellType.ColumnHeader) | ||||||||||||||
| .AddClass("col-pinned-left", Column?.Pin == DataGridColumnPin.Left) | ||||||||||||||
| .AddClass("col-pinned-right", Column?.Pin == DataGridColumnPin.Right) | ||||||||||||||
| .AddClass("col-pinned-start", Column?.Pin == DataGridColumnPin.Start) | ||||||||||||||
| .AddClass("col-pinned-end", Column?.Pin == DataGridColumnPin.End) | ||||||||||||||
|
Comment on lines
+34
to
+35
|
||||||||||||||
| .AddClass("col-pinned-start", Column?.Pin == DataGridColumnPin.Start) | |
| .AddClass("col-pinned-end", Column?.Pin == DataGridColumnPin.End) | |
| .AddClass("col-pinned-start", Column?.Pin == DataGridColumnPin.Start) | |
| .AddClass("col-pinned-left", Column?.Pin == DataGridColumnPin.Start) | |
| .AddClass("col-pinned-end", Column?.Pin == DataGridColumnPin.End) | |
| .AddClass("col-pinned-right", Column?.Pin == DataGridColumnPin.End) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to stay in place. Is used for the demo site nav menu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a0f46eb by restoring the page front matter (
titleandroute) so the demo nav/menu registration stays intact.