RadzenDataGrid: OrderByDescending not working correctly #348

Closed
opened 2026-01-29 17:35:52 +00:00 by claunia · 1 comment
Owner

Originally created by @axylophon on GitHub (Mar 24, 2022).

Describe the bug
OrderByDescending has a different behaviour than OrderBy.
OrderByDescending is not working correctly
OrderBy is working correctly

To Reproduce
Steps to reproduce the behavior:

  1. Call OrderByDescending in OnAfterRenderAsync when firstRender = true, with a string column or a column which contains nulls (dates)
  2. Grid is not sorted correctly

Expected behavior
Grid is sorted correctly

Desktop (please complete the following information):

  • Version 3.17.0

Additional context
The implementation is completely different in comparison to OrderBy:

      public void OrderBy(string property)
      {
          var p = IsOData() ? property.Replace('.', '/') : PropertyAccess.GetProperty(property);

          var column = allColumns.ToList().Where(c => c.GetSortProperty() == property).FirstOrDefault();

          if (column != null)
          {
              SetColumnSortOrder(column);
              Sort.InvokeAsync(new DataGridColumnSortEventArgs<TItem>() { Column = column, SortOrder = column.GetSortOrder() });
          }

          if (LoadData.HasDelegate && IsVirtualizationAllowed())
          {
              Data = null;
          }

          InvokeAsync(Reload);
      }

      public void OrderByDescending(string property)
      {
          var column = allColumns.ToList().Where(c => c.GetSortProperty() == property).FirstOrDefault();
          if (column != null)
          {
              column.SetSortOrder(SortOrder.Descending);
          }
          InvokeAsync(Reload);
      }
Originally created by @axylophon on GitHub (Mar 24, 2022). **Describe the bug** OrderByDescending has a different behaviour than OrderBy. OrderByDescending is **not** working correctly OrderBy is working correctly **To Reproduce** Steps to reproduce the behavior: 1. Call OrderByDescending in OnAfterRenderAsync when firstRender = true, with a string column or a column which contains nulls (dates) 2. Grid is not sorted correctly **Expected behavior** Grid is sorted correctly **Desktop (please complete the following information):** - Version 3.17.0 **Additional context** The implementation is completely different in comparison to OrderBy: ``` public void OrderBy(string property) { var p = IsOData() ? property.Replace('.', '/') : PropertyAccess.GetProperty(property); var column = allColumns.ToList().Where(c => c.GetSortProperty() == property).FirstOrDefault(); if (column != null) { SetColumnSortOrder(column); Sort.InvokeAsync(new DataGridColumnSortEventArgs<TItem>() { Column = column, SortOrder = column.GetSortOrder() }); } if (LoadData.HasDelegate && IsVirtualizationAllowed()) { Data = null; } InvokeAsync(Reload); } public void OrderByDescending(string property) { var column = allColumns.ToList().Where(c => c.GetSortProperty() == property).FirstOrDefault(); if (column != null) { column.SetSortOrder(SortOrder.Descending); } InvokeAsync(Reload); } ```
Author
Owner

@axylophon commented on GitHub (Mar 25, 2022):

Thank you for the fast response but I think it is not fixed 100%? I added a comment to the commit.

@axylophon commented on GitHub (Mar 25, 2022): Thank you for the fast response but I think it is not fixed 100%? I added a comment to the commit.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#348