Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
93f6cf9
- Add enums
vnbaaij Jun 12, 2025
b255f69
- Add DataGrid component
vnbaaij Jun 12, 2025
96e40df
Add DataGridGeneratedHeaderType
vnbaaij Jun 12, 2025
f6d0fb1
Merge branch 'users/vnbaaij/dev-v5/datagrid-part1' into users/vnbaaij…
vnbaaij Jun 12, 2025
1059dbe
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/datagrid-part1
dvoituron Jun 12, 2025
595ff78
Fix analyzer errors
vnbaaij Jun 12, 2025
b1cf680
- Add Typical demo and flags
vnbaaij Jun 12, 2025
8393e35
Work on review comments
vnbaaij Jun 12, 2025
8cd48c6
Merge branch 'users/vnbaaij/dev-v5/datagrid-part1' of https://github.…
vnbaaij Jun 12, 2025
202c10a
Process review comments
vnbaaij Jun 12, 2025
5aa2c65
Add language resources
vnbaaij Jun 12, 2025
777e854
Add Unit Tests for Paginator
vnbaaij Jun 12, 2025
448c89e
More review comments
vnbaaij Jun 13, 2025
3146aeb
Update tests. Now 100% lc
vnbaaij Jun 13, 2025
69ffae6
- Add Typical demo and flags
vnbaaij Jun 13, 2025
35e0334
Replace tokens (WIP)
vnbaaij Jun 13, 2025
b92c83c
Remove flags. These will be added to sample data project in separate PR
vnbaaij Jun 17, 2025
430abd5
Remove DI abstractions package. Not needed
vnbaaij Jun 17, 2025
d0c1052
Merge dev-v5
vnbaaij Jun 17, 2025
33af462
Add IsFixed parameter
vnbaaij Jun 17, 2025
689fe43
merge dev-v5
vnbaaij Jun 17, 2025
44f7d0d
MAke example grid mor functional and look better
vnbaaij Jun 17, 2025
6fc0809
Add initial tests. They are not passing yet
vnbaaij Jun 18, 2025
5bcb9fa
Add surpression atribute, fix other analyzer warnings
vnbaaij Jun 18, 2025
a30dabf
Use localized strings
vnbaaij Jun 18, 2025
aadf080
Merg dev-v5
vnbaaij Jun 18, 2025
70c342b
Fix tests
vnbaaij Jun 18, 2025
b826128
Add Tests
vnbaaij Jun 19, 2025
d0979ea
Add tests for PaginatinState and TotalItemCountChangedEventArgs
vnbaaij Jun 19, 2025
a6aa6fc
Merge branch 'users/vnbaaij/dev-v5/pagination-tests' into users/vnbaa…
vnbaaij Jun 19, 2025
613cbd0
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/pagination-tests
vnbaaij Jun 19, 2025
af4f1e8
Add Row tests
vnbaaij Jun 19, 2025
89038a7
process review comments
vnbaaij Jun 19, 2025
bcdffd9
Merge branch 'users/vnbaaij/dev-v5/pagination-tests' into users/vnbaa…
vnbaaij Jun 19, 2025
ba9c0fb
More tests
vnbaaij Jun 19, 2025
924df75
More tests
vnbaaij Jun 19, 2025
726cf24
Merge branch 'users/vnbaaij/dev-v5/datagrid-part2' of https://github.…
vnbaaij Jun 20, 2025
8fe02c0
- Add typical demo
vnbaaij Jun 23, 2025
abb696c
More tests
vnbaaij Jun 29, 2025
4aae12f
- More tests
vnbaaij Jun 29, 2025
39dc140
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/datagrid-part2
vnbaaij Jul 1, 2025
f4b691a
Update file headers
vnbaaij Jul 1, 2025
1f50f07
Convert DataGrid JS to TS
vnbaaij Jul 1, 2025
097db2f
Implement fix for #3963
vnbaaij Jul 1, 2025
713d96b
Bring in changes made in v4 with #3949
vnbaaij Jul 1, 2025
2698837
- Update file headers
vnbaaij Jul 1, 2025
460a82f
Merge branch 'users/vnbaaij/dev-v5/datagrid-part2' into users/vnbaaij…
vnbaaij Jul 1, 2025
f9ce111
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/datagrid-part3
vnbaaij Jul 2, 2025
ab02f1c
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/datagrid-part2
vnbaaij Jul 2, 2025
088dd55
Process review comments:
vnbaaij Jul 2, 2025
ede49e6
Forgot to change the docs
vnbaaij Jul 2, 2025
87cb81a
Merge branch 'users/vnbaaij/dev-v5/datagrid-part2' into users/vnbaaij…
vnbaaij Jul 2, 2025
d47fc5e
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/datagrid-part2
vnbaaij Jul 2, 2025
f921191
- Use auto-generated constant
vnbaaij Jul 2, 2025
25e046e
Merge branch 'users/vnbaaij/dev-v5/datagrid-part2' of https://github.…
vnbaaij Jul 2, 2025
e6ec4a3
DataGrid docs and examples
vnbaaij Jul 2, 2025
07365bd
Merge branch 'users/vnbaaij/dev-v5/datagrid-part3' into users/vnbaaij…
vnbaaij Jul 2, 2025
5af4579
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/datagrid-part4
vnbaaij Jul 2, 2025
66af301
Merge branch 'users/vnbaaij/dev-v5/datagrid-part2' into users/vnbaaij…
vnbaaij Jul 3, 2025
9e89b82
Merge branch 'users/vnbaaij/dev-v5/datagrid-part3' into users/vnbaaij…
vnbaaij Jul 3, 2025
855fe34
Merge branch 'users/vnbaaij/dev-v5/datagrid-part4' of https://github.…
vnbaaij Jul 3, 2025
e3c942f
Process review comments
vnbaaij Jul 3, 2025
f6d458b
More review comments
vnbaaij Jul 3, 2025
64cf5bb
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/datagrid-part2
vnbaaij Jul 3, 2025
85154bf
- Undo make internal GridItemsProvider*
vnbaaij Jul 3, 2025
ed02449
Update test verified files
vnbaaij Jul 3, 2025
770c533
merge part 2
vnbaaij Jul 3, 2025
c6a2f1b
Merge branch 'users/vnbaaij/dev-v5/datagrid-part3' into users/vnbaaij…
vnbaaij Jul 3, 2025
d0246dd
Merge dev-v5
vnbaaij Jul 3, 2025
36dc27b
- Fix when to show header menu
vnbaaij Jul 3, 2025
150c1fd
- Rename getting started
vnbaaij Jul 3, 2025
567729b
WIP
vnbaaij Jul 18, 2025
61deb6a
Update samples and structure
vnbaaij Jul 21, 2025
e1932a6
Make all DataGrid samples work
vnbaaij Jul 21, 2025
62753d4
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/datagrid-part4
vnbaaij Jul 21, 2025
7c4f77b
Update DataGrid verified tests files
vnbaaij Jul 21, 2025
998b8c9
Merge branch 'users/vnbaaij/dev-v5/datagrid-part4' of https://github.…
vnbaaij Jul 21, 2025
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
Prev Previous commit
Next Next commit
- More tests
- Fix ToDo items
- Misc code changes
  • Loading branch information
vnbaaij committed Jul 1, 2025
commit 4aae12f6455e61fa445dd3e3f3052f48f5033d0c
2 changes: 2 additions & 0 deletions spelling.dic
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,5 @@ eventargs
Subscribable
colspan
Voituron
firstname
lastname
150 changes: 75 additions & 75 deletions src/Core/Components/DataGrid/Columns/ColumnBase.razor
Original file line number Diff line number Diff line change
Expand Up @@ -29,70 +29,68 @@
{
string? tooltip = Tooltip ? (HeaderTooltip ?? Title) : null;

<FluentKeyCode Only="@(new[] { KeyCode.KeyR })" OnKeyDown="HandleKeyDownAsync" class="keycapture" style="width: 100%;" StopPropagation="true" @oncontextmenu="@(() => Grid.RemoveSortByColumnAsync(this))">

@if (AnyColumnActionEnabled)
{
<FluentButton Disabled="@(!AnyColumnActionEnabled)" Id="@_columnId" Appearance="ButtonAppearance.Subtle" Class="col-sort-button" Style="width: calc(100% - 10px);" @onclick="@HandleColumnHeaderClickedAsync" aria-label="@tooltip" title="@tooltip">
<div class="col-title-text" title="@tooltip">
@HeaderTitleContent
</div>
@if (AnyColumnActionEnabled)
{
<FluentButton Id="@_columnId" Appearance="ButtonAppearance.Subtle" Class="col-sort-button" Style="width: calc(100% - 10px);" @onclick="@HandleColumnHeaderClickedAsync" aria-label="@tooltip" title="@tooltip" @oncontextmenu="@(() => Grid.RemoveSortByColumnAsync(this))">
<div class="col-title-text" title="@tooltip">
@HeaderTitleContent
</div>

@if (Grid.SortByAscending.HasValue && IsActiveSortColumn)
@if (Grid.SortByAscending.HasValue && IsActiveSortColumn)
{
if (Grid.SortByAscending == true)
{
if (Grid.SortByAscending == true)
{
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortUp())" Slot="@(Align == HorizontalAlignment.End ? "start" : "end")" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
else
{
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortDown())" Slot="@(Align == HorizontalAlignment.End ? "start" : "end")" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortUp())" Slot="@(Align == HorizontalAlignment.End ? "start" : "end")" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
@if (ColumnOptions is not null && Filtered.GetValueOrDefault())
else
{
<FluentIcon Value="@(new CoreIcons.Regular.Size20.Filter())" Slot="@(Align == HorizontalAlignment.End ? "start" : "end")" Style="opacity: var(--fluent-data-grid-header-opacity);" />
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortDown())" Slot="@(Align == HorizontalAlignment.End ? "start" : "end")" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
</FluentButton>
}
else
{
<div class="col-title">
<div class="col-title-text" title="@tooltip">
@HeaderTitleContent
</div>
}
@if (ColumnOptions is not null && Filtered.GetValueOrDefault())
{
<FluentIcon Value="@(new CoreIcons.Regular.Size20.Filter())" Slot="@(Align == HorizontalAlignment.End ? "start" : "end")" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
</FluentButton>
}
else
{
<div class="col-title">
<div class="col-title-text" title="@tooltip">
@HeaderTitleContent
</div>
}
<FluentMenu @ref="@_menu" Trigger="@_columnId">
<FluentMenuList>
@if (Sortable.HasValue ? Sortable.Value : IsSortableByDefault())
{
<FluentMenuItem OnClick="@(async () => await Grid.SortByColumnAsync(this))" @onkeydown="HandleSortMenuKeyDownAsync"
IconStart="@(Grid.ColumnSortUISettings.Icon is not null && Grid.ColumnSortUISettings.IconPositionStart ? Grid.ColumnSortUISettings.Icon : null)"
IconEnd="@(Grid.ColumnSortUISettings.Icon is not null && !Grid.ColumnSortUISettings.IconPositionStart ? Grid.ColumnSortUISettings.Icon : null)">
@GetSortOptionText()
</div>
}
<FluentMenu @ref="@_menu" Trigger="@_columnId">
<FluentMenuList>
@if (Sortable.HasValue ? Sortable.Value : IsSortableByDefault())
{
<FluentMenuItem OnClick="@(async () => await Grid.SortByColumnAsync(this))" @onkeydown="HandleSortMenuKeyDownAsync"
IconStart="@(Grid.ColumnSortUISettings.Icon is not null && Grid.ColumnSortUISettings.IconPositionStart ? Grid.ColumnSortUISettings.Icon : null)"
IconEnd="@(Grid.ColumnSortUISettings.Icon is not null && !Grid.ColumnSortUISettings.IconPositionStart ? Grid.ColumnSortUISettings.Icon : null)">
@GetSortOptionText()

</FluentMenuItem>
}
@if (Grid.ResizeType is not null && Grid.ResizableColumns)
{
<FluentMenuItem OnClick="@(async () => await Grid.ShowColumnResizeAsync(this))" @onkeydown="HandleResizeMenuKeyDownAsync"
IconStart="@(Grid.ColumnResizeUISettings.Icon is not null && Grid.ColumnResizeUISettings.IconPositionStart ? Grid.ColumnResizeUISettings.Icon : null)"
IconEnd="@(Grid.ColumnResizeUISettings.Icon is not null && !Grid.ColumnResizeUISettings.IconPositionStart ? Grid.ColumnResizeUISettings.Icon : null)">
@Localizer[Localization.LanguageResource.DataGrid_ResizeMenu]
</FluentMenuItem>
}
@if (ColumnOptions is not null)
{
<FluentMenuItem OnClick="@(async () => await Grid.ShowColumnOptionsAsync(this))" @onkeydown="HandleOptionsMenuKeyDownAsync"
IconStart="@(Grid.ColumnOptionsUISettings.Icon is not null && Grid.ColumnOptionsUISettings.IconPositionStart ? Grid.ColumnOptionsUISettings.Icon : null)"
IconEnd="@(Grid.ColumnOptionsUISettings.Icon is not null && !Grid.ColumnOptionsUISettings.IconPositionStart ? Grid.ColumnOptionsUISettings.Icon : null)">
@Localizer[Localization.LanguageResource.DataGrid_OptionsMenu]
</FluentMenuItem>
}
</FluentMenuList>
</FluentMenu>

</FluentMenuItem>
}
@if (Grid.ResizeType is not null && Grid.ResizableColumns)
{
<FluentMenuItem OnClick="@(async () => await Grid.ShowColumnResizeAsync(this))" @onkeydown="HandleResizeMenuKeyDownAsync"
IconStart="@(Grid.ColumnResizeUISettings.Icon is not null && Grid.ColumnResizeUISettings.IconPositionStart ? Grid.ColumnResizeUISettings.Icon : null)"
IconEnd="@(Grid.ColumnResizeUISettings.Icon is not null && !Grid.ColumnResizeUISettings.IconPositionStart ? Grid.ColumnResizeUISettings.Icon : null)">
@Localizer[Localization.LanguageResource.DataGrid_ResizeMenu]
</FluentMenuItem>
}
@if (ColumnOptions is not null)
{
<FluentMenuItem OnClick="@(async () => await Grid.ShowColumnOptionsAsync(this))" @onkeydown="HandleOptionsMenuKeyDownAsync"
IconStart="@(Grid.ColumnOptionsUISettings.Icon is not null && Grid.ColumnOptionsUISettings.IconPositionStart ? Grid.ColumnOptionsUISettings.Icon : null)"
IconEnd="@(Grid.ColumnOptionsUISettings.Icon is not null && !Grid.ColumnOptionsUISettings.IconPositionStart ? Grid.ColumnOptionsUISettings.Icon : null)">
@Localizer[Localization.LanguageResource.DataGrid_OptionsMenu]
</FluentMenuItem>
}
</FluentMenuList>
</FluentMenu>
</FluentKeyCode>
}
else
{
Expand Down Expand Up @@ -127,29 +125,29 @@

@if (Sortable.HasValue ? Sortable.Value : IsSortableByDefault())
{
<FluentKeyCode Only="new[] { KeyCode.Ctrl, KeyCode.Enter }" OnKeyDown="HandleKeyDownAsync" class="keycapture" style="width: 100%;" StopPropagation="true" @oncontextmenu="@(() => Grid.RemoveSortByColumnAsync(this))">
<FluentButton Appearance="ButtonAppearance.Subtle" Class="col-sort-button" Style="@($"width: calc(100% - {wdelta});")" @onclick="@(() => Grid.SortByColumnAsync(this))" aria-label="@tooltip" title="@tooltip">
<div class="col-title-text" title="@tooltip">
@HeaderTitleContent
</div>

@if (Grid.SortByAscending.HasValue && IsActiveSortColumn)
<FluentButton Appearance="ButtonAppearance.Subtle" Class="col-sort-button" Style="@($"width: calc(100% - {wdelta});")" @onclick="@(() => Grid.SortByColumnAsync(this))" aria-label="@tooltip" title="@tooltip" @oncontextmenu="@(() => Grid.RemoveSortByColumnAsync(this))">
<div class="col-title-text" title="@tooltip">
@HeaderTitleContent
</div>

@if (Grid.SortByAscending.HasValue && IsActiveSortColumn)
{
if (Grid.SortByAscending == true)
{
if (Grid.SortByAscending == true)
{
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortUp())" Slot="end" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
else
{
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortDown())" Slot="end" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortUp())" Slot="end" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
@if (ColumnOptions is not null && Filtered.GetValueOrDefault())
else
{
<FluentIcon Value="@(Grid.ColumnOptionsUISettings.Icon)" Slot="end" Style="opacity: var(--fluent-data-grid-header-opacity);" />
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortDown())" Slot="end" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
</FluentButton>
</FluentKeyCode>
}
@if (ColumnOptions is not null && Filtered.GetValueOrDefault())
{
<FluentIcon Value="@(Grid.ColumnOptionsUISettings.Icon)" Slot="end" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
</FluentButton>

}
else
{
Expand Down Expand Up @@ -185,6 +183,8 @@
}
}

[ExcludeFromCodeCoverage(Justification = "This method can't be tested because of Virtualization (which does not render completely under bUnit).")]

internal void RenderPlaceholderContent(RenderTreeBuilder __builder, PlaceholderContext placeholderContext)
{
// Blank if no placeholder template was supplied, as it's enough to style with CSS by default
Expand Down
20 changes: 5 additions & 15 deletions src/Core/Components/DataGrid/Columns/ColumnBase.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// MIT License - Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------------------

using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering;
using Microsoft.AspNetCore.Components.Web;
Expand Down Expand Up @@ -247,6 +248,7 @@ protected internal virtual Task OnCellClickAsync(FluentDataGridCell<TGridItem> c
/// <param name="cell"></param>
/// <param name="args"></param>
/// <returns></returns>
[ExcludeFromCodeCoverage(Justification = "This method is virtual. It is not called directly on this type.")]
protected internal virtual Task OnCellKeyDownAsync(FluentDataGridCell<TGridItem> cell, KeyboardEventArgs args)
{
return Task.CompletedTask;
Expand All @@ -257,12 +259,14 @@ protected internal virtual Task OnCellKeyDownAsync(FluentDataGridCell<TGridItem>
/// </summary>
/// <param name="builder">The current <see cref="RenderTreeBuilder" />.</param>
/// <param name="item">The data for the row being rendered.</param>

protected internal abstract void CellContent(RenderTreeBuilder builder, TGridItem item);

/// <summary>
/// Overridden by derived components to provide the raw content for the column's cells.
/// </summary>
/// <param name="item">The data for the row being rendered.</param>
[ExcludeFromCodeCoverage(Justification = "This method is virtual. It is not called directly on this type.")]
protected internal virtual string? RawCellContent(TGridItem item) => null;

/// <summary>
Expand All @@ -273,23 +277,9 @@ protected internal virtual Task OnCellKeyDownAsync(FluentDataGridCell<TGridItem>
/// Derived components may override this to implement alternative default sortabillity rules.
/// </summary>
/// <returns>True if the column should be sortable by default, otherwise false.</returns>
[ExcludeFromCodeCoverage(Justification = "This method is virtual. It is not called directly on this type.")]
protected virtual bool IsSortableByDefault() => false;

/// <summary>
/// Handles the key down event and performs actions based on the key combination pressed.
/// </summary>
/// <remarks>If the <see cref="FluentKeyCodeEventArgs.ShiftKey"/> is pressed and the key is <see
/// cref="KeyCode.KeyR"/>, this method triggers the removal of sorting for the associated grid column
/// asynchronously.</remarks>
/// <param name="e">The event arguments containing details about the key press, including the key code and modifier keys.</param>
protected async Task HandleKeyDownAsync(FluentKeyCodeEventArgs e)
{
if (e.ShiftKey && e.Key == KeyCode.KeyR)
{
await Grid.RemoveSortByColumnAsync(this);
}
}

private async Task HandleColumnHeaderClickedAsync()
{
var hasSorting = Sortable is true || IsDefaultSortColumn;
Expand Down
15 changes: 8 additions & 7 deletions src/Core/Components/DataGrid/Columns/ColumnKeyGridSort.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ------------------------------------------------------------------------
// MIT License - Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------------------

namespace Microsoft.FluentUI.AspNetCore.Components;

/// <summary>
Expand All @@ -10,11 +11,11 @@ namespace Microsoft.FluentUI.AspNetCore.Components;
public sealed class ColumnKeyGridSort<TGridItem> : IGridSort<TGridItem>
{
private readonly string _columnKey;
private readonly Func<IQueryable<TGridItem>, bool, IOrderedQueryable<TGridItem>>? _sortFunction;
private readonly Func<IQueryable<TGridItem>, bool, IOrderedQueryable<TGridItem>> _sortFunction;

internal ColumnKeyGridSort(
string columnKey,
Func<IQueryable<TGridItem>, bool, IOrderedQueryable<TGridItem>>? sortFunction = null)
Func<IQueryable<TGridItem>, bool, IOrderedQueryable<TGridItem>> sortFunction)
{
_columnKey = columnKey;
_sortFunction = sortFunction;
Expand All @@ -28,13 +29,13 @@ internal ColumnKeyGridSort(
/// <returns> /// <returns>The ordered collection</returns></returns>
public IOrderedQueryable<TGridItem> Apply(IQueryable<TGridItem> queryable, bool ascending)
{
if (_sortFunction != null)
{
return _sortFunction(queryable, ascending);
}
//if (_sortFunction != null)
//{
return _sortFunction(queryable, ascending);
//}

// If no sort is provided, apply a sort that has no affect in order to be able to return an IOrderedQueryable
return queryable.OrderBy(x => 0);
//return queryable.OrderBy(x => 0);
}

/// <summary>
Expand Down
31 changes: 17 additions & 14 deletions src/Core/Components/DataGrid/Columns/GridSort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private List<SortedProperty> BuildPropertyList(bool ascending)

// Not sure we really want this level of complexity, but it converts expressions like @(c => c.Medals.Gold) to "Medals.Gold"
// Makes it too complex to test, so we exclude from coverage
[ExcludeFromCodeCoverage(Justification = "Too complex to write test for.")]
[ExcludeFromCodeCoverage(Justification = "Find a way to test this at a later date.")]
#pragma warning disable MA0015 // Specify the parameter name in ArgumentException
private static string ToPropertyName(LambdaExpression expression)
{
Expand Down Expand Up @@ -297,22 +297,25 @@ private static string ToPropertyName(LambdaExpression expression)
}
}

// Now construct the string
return string.Create(length, body, (chars, body) =>
return string.Create(length, body, action);
}

[ExcludeFromCodeCoverage(Justification = "Find a way to test this at a later date.")]
private static void action(Span<char> chars, MemberExpression body)
{

var nextPos = chars.Length;
while (body is not null)
{
var nextPos = chars.Length;
while (body is not null)
nextPos -= body.Member.Name.Length;
body.Member.Name.CopyTo(chars[nextPos..]);
if (nextPos > 0)
{
nextPos -= body.Member.Name.Length;
body.Member.Name.CopyTo(chars[nextPos..]);
if (nextPos > 0)
{
chars[--nextPos] = '.';
}

body = (body.Expression as MemberExpression)!;
chars[--nextPos] = '.';
}
});

body = (body.Expression as MemberExpression)!;
}
}
}
#pragma warning restore MA0015 // Specify the parameter name in ArgumentException
8 changes: 5 additions & 3 deletions src/Core/Components/DataGrid/Columns/SelectColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public DataGridSelectMode SelectMode

/// <inheritdoc />
[Parameter]
public override IGridSort<TGridItem>? SortBy { get; set; }
public override IGridSort<TGridItem>? SortBy { get; set; } = null;

/// <summary>
/// Allows to clear the selection.
Expand Down Expand Up @@ -516,8 +516,10 @@ protected internal override void CellContent(RenderTreeBuilder builder, TGridIte
return TooltipText?.Invoke(item);
}

/// <inheritdoc />
protected override bool IsSortableByDefault() => SortBy is not null;
/// <summary >
/// A <see cref="FluentDataGrid{TGridItem}"/> cannot be sorted on a <see cref="SelectColumn{TGridItem}"/>.
/// </summary>
protected override bool IsSortableByDefault() => false;

/// <summary />
internal async Task OnClickAllAsync(MouseEventArgs e)
Expand Down
Loading