Custom comparer
Here a custom comparer is being used to sort counties by the length of their name. The code has examples for both
PropertyColumn
and TemplateColumn
implementations (see the Razor tab).
For this example the code for the comparer is placed in the DataGridCustomComparer.razor.cs
file but it
could of course be placed in its own file.
For the paginator, this example also shows how to use the SummaryTemplate
and PaginationTextTemplate
parameters.
This example also shows using an OnRowFocus
event callback to detect which row the cursor is over. By setting ShowHover
to true, the current row will be highlighted. By default the system will use the designated hover color for this but you can specify an alternative
color by setting the --datagrid-hover-color
CSS variable. See the Razor tab for how this is done in this example.
To show how the resize handle can be altered, when choosing to use the alternate hover color, the handle color is set to a different value.
Note: once a value has been selected for the Resize type, it cannot by set to null again. You need to refresh the page to start with a null value again.
Rank | Name | Gold | Silver | Bronze | Total |
---|---|---|---|---|---|
People's Republic of China | 40 | 27 | 24 | 91 | |
United States of America | 40 | 44 | 42 | 126 | |
Refugee Olympic Team | 0 | 0 | 1 | 1 | |
Dominican Republic | 1 | 0 | 2 | 3 | |
Czech Republic | 3 | 0 | 2 | 5 | |
Chinese Taipei | 2 | 0 | 5 | 7 | |
Great Britain | 14 | 22 | 29 | 65 | |
South Africa | 1 | 3 | 2 | 6 | |
Ivory Coast | 0 | 0 | 1 | 1 | |
South Korea | 13 | 9 | 10 | 32 |