QuickGrid for Blazor


Sorting is controlled by columns.

  • For a PropertyColumn, sorting is enabled if you set Sortable="true". You should do this only if your underlying data source supports sorting by this column's property expression.
  • For a TemplateColumn, sorting is enabled if you supply a value for the column's SortBy parameter.
  • For a custom column inherited from ColumnBase, sorting is enabled if you set Sortable="true" or if you override IsSortableByDefault and return true.

You can also specify IsDefaultSort on a column with value SortDirection.Ascending or SortDirection.Descending to indicate the grid's initial sort order.

Sorting and remote data (ItemsProvider)

If you are using an ItemsProvider callback, the request parameter gives you access to the current sort order. It's up to you to translate this into whatever kind of parameters are supported by your underlying data source.

In most cases you should do this by calling request.GetSortByProperties() to get a list of the sort property names and directions. This will work as long as:

  • The current sort column implements ISortBuilderColumn (the built-in ones do)
  • ... and the current sort order is expressible as a simple chain of property names. For example:
    • A PropertyColumn with Property="@(x => x.Medals.Gold)" is OK, and will give the sort property name "Medals.Gold"
    • A PropertyColumn with Property="@(x => x.Width * x.Length)" is not OK, and will make GetSortByProperties throw an exception.

If you have a column whose sort expression can't be expressed as a chain of property names, then instead of calling GetSortByProperties, you will need to read request.SortByColumn and request.SortByAscending and use your own knowledge of the column to convert this into parameter values for your underlying data source.

An unhandled error has occurred. Reload 🗙