New to Telerik UI for WPF? Download free 30-day trial

Use Expression Descriptors

This help article will show you how to create generic expression descriptors (SortDescriptor, GroupDescriptors and FilterDescriptors) for RadGridView.

Sorting

You can order your data items by the result of a complex calculation without having to expose it through a read-only property. All you need to do is to use the new SortDescriptor:

Example 1: Create a generic SortDescriptor.

var descriptor = new SortDescriptor<Employee, double> 
{ 
    SortingExpression = e => e.Orders.SelectMany(o => o.Details).Sum(d => d.UnitPrice * d.Quantity), 
    SortDirection = ListSortDirection.Descending 
}; 
Then, you should add the defined SortDescriptor to the SortDescriptors collection of RadGridView.

For more information you can check the Sorting section

Grouping

You can also group objects by the result of an equally complex operation:

Example 2: Create a generic GroupDescriptor.

var descriptor = new GroupDescriptor<Employee, int, int> 
{ 
    GroupingExpression = e => e.Orders.Where(o => o.Details.Any(d => d.Product.ProductName.Contains("Syrup"))).Count(), 
    SortDirection = ListSortDirection.Ascending 
}; 
Then, add the defined GroupDescriptor to the GroupDescriptors collection of RadGridView.

For more information you can check the Grouping section

Filtering

The new FilterDescriptor allows you to directly plug a predicate that determines which items are filtered. You just need to set a lambda to the FilteringExpression property like so:

Example 3: Create a generic FilterDescriptor.

var descriptor = new FilterDescriptor<Employee> { FilteringExpression = e => prospects.Contains(e) }; 
Then, you should add the defined FilterDescriptor to the FilterDescriptors collection of RadGridView.

For more information you can check the Filtering section

In this article