diff --git a/examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml b/examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml index 3207944bf1..ef69634a33 100644 --- a/examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml +++ b/examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml @@ -2373,6 +2373,11 @@ Gets a reference to the enclosing . + + + Gets the columns associated with this data grid row. + + diff --git a/src/Core/Components/DataGrid/FluentDataGridCell.razor.cs b/src/Core/Components/DataGrid/FluentDataGridCell.razor.cs index 8c2e54b15e..03827a46bb 100644 --- a/src/Core/Components/DataGrid/FluentDataGridCell.razor.cs +++ b/src/Core/Components/DataGrid/FluentDataGridCell.razor.cs @@ -53,7 +53,7 @@ public partial class FluentDataGridCell : FluentComponentBase /// /// Gets a reference to the column that this cell belongs to. /// - private ColumnBase? Column => Grid._columns.ElementAtOrDefault(GridColumn - 1); + public ColumnBase? Column => Grid._columns.ElementAtOrDefault(GridColumn - 1); /// /// Gets a reference to the enclosing . diff --git a/src/Core/Components/DataGrid/FluentDataGridRow.razor.cs b/src/Core/Components/DataGrid/FluentDataGridRow.razor.cs index a7ca7791dc..5b136e8ad9 100644 --- a/src/Core/Components/DataGrid/FluentDataGridRow.razor.cs +++ b/src/Core/Components/DataGrid/FluentDataGridRow.razor.cs @@ -63,6 +63,11 @@ public partial class FluentDataGridRow : FluentComponentBase, IHandle /// protected FluentDataGrid Grid => InternalGridContext.Grid; + /// + /// Gets the columns associated with this data grid row. + /// + public IReadOnlyList> Columns => Grid._columns; + protected string? ClassValue => new CssBuilder(Class) .AddClass("fluent-data-grid-row") .AddClass("hover", when: Grid.ShowHover) diff --git a/tests/Core/DataGrid/DataGridColumnsPropertyTestsRazor.razor b/tests/Core/DataGrid/DataGridColumnsPropertyTestsRazor.razor new file mode 100644 index 0000000000..4faee11bdf --- /dev/null +++ b/tests/Core/DataGrid/DataGridColumnsPropertyTestsRazor.razor @@ -0,0 +1,41 @@ +@using Xunit; +@inherits TestContext +@code +{ + public DataGridColumnsPropertyTestsRazor() + { + JSInterop.Mode = JSRuntimeMode.Loose; + Services.AddSingleton(LibraryConfiguration.ForUnitTests); + + // Register Service + var keycodeService = new KeyCodeService(); + Services.AddScoped(factory => keycodeService); + } + + private record TestItem(int Id, string Name); + + private readonly IQueryable TestData = new[] + { + new TestItem(1, "First Item"), + new TestItem(2, "Second Item"), + }.AsQueryable(); + + [Fact] + public void DataGrid_Properties_AccessibilityTest() + { + // Arrange & Act + var cut = Render( + @ + + + + ); + + // Assert that grid was rendered successfully + Assert.NotNull(cut); + + // The fact that this test compiles and renders successfully + // validates that our public properties are correctly exposed + Assert.True(true, "DataGrid rendered successfully with public Column properties accessible"); + } +} \ No newline at end of file diff --git a/tests/Core/DataGrid/FluentDataGridTests.razor b/tests/Core/DataGrid/FluentDataGridTests.razor index 0d1cacb637..2f61317ebc 100644 --- a/tests/Core/DataGrid/FluentDataGridTests.razor +++ b/tests/Core/DataGrid/FluentDataGridTests.razor @@ -12,6 +12,28 @@ Services.AddScoped(factory => new KeyCodeService()); } + [Fact] + public void DataGrid_Properties_CompileCorrectly() + { + // This test verifies that our new public properties compile correctly + // by checking that they exist and are public using reflection + + var rowType = typeof(FluentDataGridRow); + var cellType = typeof(FluentDataGridCell); + + // Verify that the Columns property exists on DataGridRow + var columnsProperty = rowType.GetProperty("Columns"); + Assert.NotNull(columnsProperty); + Assert.True(columnsProperty.CanRead); + Assert.True(columnsProperty.GetMethod?.IsPublic == true); + + // Verify that the Column property exists on DataGridCell + var columnProperty = cellType.GetProperty("Column"); + Assert.NotNull(columnProperty); + Assert.True(columnProperty.CanRead); + Assert.True(columnProperty.GetMethod?.IsPublic == true); + } + [Fact] public void FluentDataGrid_Default() {