From 2ff71cae718ce30653aebd2c26167147927ac6f9 Mon Sep 17 00:00:00 2001 From: Chris Pettit Date: Wed, 23 Apr 2025 11:59:06 -0500 Subject: [PATCH] Grid_RowKeySelector Add the ability to specify a RowKeySelector for a Grid to override the default GetHashCode for Row Keys in the Grid --- blazorbootstrap/Components/Grid/Grid.razor | 2 +- blazorbootstrap/Components/Grid/Grid.razor.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/blazorbootstrap/Components/Grid/Grid.razor b/blazorbootstrap/Components/Grid/Grid.razor index f3ceacba9..1b6771be7 100644 --- a/blazorbootstrap/Components/Grid/Grid.razor +++ b/blazorbootstrap/Components/Grid/Grid.razor @@ -147,7 +147,7 @@ { var rowClass = RowClass?.Invoke(item) ?? ""; var detailViewRowId = IdUtility.GetNextId(); - + @if (AllowDetailView) { diff --git a/blazorbootstrap/Components/Grid/Grid.razor.cs b/blazorbootstrap/Components/Grid/Grid.razor.cs index df5870e70..91d372216 100644 --- a/blazorbootstrap/Components/Grid/Grid.razor.cs +++ b/blazorbootstrap/Components/Grid/Grid.razor.cs @@ -995,6 +995,14 @@ private void SetFilters(IEnumerable filterItems) [Parameter] public Func? RowClass { get; set; } + /// + /// Gets or sets the row key selector. + /// usage ex. + /// RowKeySelector="context => context.UserId" + /// + [Parameter] + public Func? RowKeySelector { get; set; } + /// /// Gets or sets the selected items. ///