diff --git a/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Examples/DataGridComparerExample.razor b/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Examples/DataGridComparerExample.razor index 2309298db3..182e3056a0 100644 --- a/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Examples/DataGridComparerExample.razor +++ b/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Examples/DataGridComparerExample.razor @@ -8,7 +8,7 @@ SortMode="DataGridSortMode.Single"> - + @($"{context.FirstName} {context.LastName}") @@ -39,9 +39,9 @@ public override int Compare(Employee x, Employee y) { // Null checks - if (x == null && y == null) return 0; - if (x == null) return -1; - if (y == null) return 1; + if (x is null && y is null) return 0; + if (x is null) return -1; + if (y is null) return 1; // Compare by length of FirstName int firstNameLengthComparison = x.FirstName.Length.CompareTo(y.FirstName.Length); diff --git a/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Features/SortingPage.razor b/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Features/SortingPage.razor index 1e3eb09728..3d2929bed8 100644 --- a/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Features/SortingPage.razor +++ b/Documentation/Blazorise.Docs/Pages/Docs/Extensions/DataGrid/Features/SortingPage.razor @@ -64,9 +64,9 @@ - + - The Comparer feature allows you to define a custom sorting logic for a column by specifying an IComparer<TItem> implementation. + The SortComparer feature allows you to define a custom sorting logic for a column by specifying an IComparer<TItem> implementation. This is useful when you want to sort data based on complex or calculated criteria that go beyond the default alphabetical or numerical order. @@ -78,7 +78,7 @@ - + diff --git a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs index 79e66bd434..b34ddec160 100644 --- a/Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs +++ b/Source/Extensions/Blazorise.DataGrid/DataGrid.razor.cs @@ -2301,15 +2301,15 @@ private void FilterData( IQueryable query ) { if ( sortByColumn.CurrentSortDirection == SortDirection.Ascending ) { - query = sortByColumn.Comparer == null + query = sortByColumn.SortComparer == null ? query.OrderBy( x => sortFunction( x ) ) - : query.OrderBy( x => x, sortByColumn.Comparer ); + : query.OrderBy( x => x, sortByColumn.SortComparer ); } else { - query = sortByColumn.Comparer == null + query = sortByColumn.SortComparer == null ? query.OrderByDescending( x => sortFunction( x ) ) - : query.OrderByDescending( x => x, sortByColumn.Comparer ); + : query.OrderByDescending( x => x, sortByColumn.SortComparer ); } firstSort = false; @@ -2318,15 +2318,15 @@ private void FilterData( IQueryable query ) { if ( sortByColumn.CurrentSortDirection == SortDirection.Ascending ) { - query = sortByColumn.Comparer == null + query = sortByColumn.SortComparer is null ? ( query as IOrderedQueryable ).ThenBy( x => sortFunction( x ) ) - : ( query as IOrderedQueryable ).ThenBy( x => x, sortByColumn.Comparer ); + : ( query as IOrderedQueryable ).ThenBy( x => x, sortByColumn.SortComparer ); } else { - query = sortByColumn.Comparer == null + query = sortByColumn.SortComparer is null ? ( query as IOrderedQueryable ).ThenByDescending( x => sortFunction( x ) ) - : ( query as IOrderedQueryable ).ThenByDescending( x => x, sortByColumn.Comparer ); + : ( query as IOrderedQueryable ).ThenByDescending( x => x, sortByColumn.SortComparer ); } } diff --git a/Source/Extensions/Blazorise.DataGrid/DataGridColumn.cs b/Source/Extensions/Blazorise.DataGrid/DataGridColumn.cs index ef3b7a9a31..b46d4110eb 100644 --- a/Source/Extensions/Blazorise.DataGrid/DataGridColumn.cs +++ b/Source/Extensions/Blazorise.DataGrid/DataGridColumn.cs @@ -748,7 +748,7 @@ public SortDirection CurrentSortDirection /// /// Gets or sets the custom comparer used for sorting the items in this column. /// - [Parameter] public IComparer Comparer { get; set; } + [Parameter] public IComparer SortComparer { get; set; } /// /// Gets or sets whether the sort direction will be reversed.