Another four months have gone by and another awesome release of RadControls has arrived!
One of the exciting new features in this release are the so-called 'Expression Descriptors'. Previously, whenever our clients wanted to filter data but needed even more control than our good old FilterDescriptor could provide, they had to subclass it and override some of its methods. Even though that approach works, it is tedious and cumbersome. And, as much as LINQ Expressions rock, having to manually generate expression trees by hand... yuck!
The new FilterDescriptor<T> 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:
var descriptor =
new
FilterDescriptor<Employee> { FilteringExpression = e => prospects.Contains(e) };
But wait, that's not all! Aside from the usual speed optimizations and performance tweaks we performed on our data engine since our last release, we also implemented support for generic GroupDescriptors and SortDescriptors, too.
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<TElement, TKey>:
var descriptor =
new
SortDescriptor<Employee,
double
>
{
SortingExpression = e => e.Orders.SelectMany(o => o.Details).Sum(d => d.UnitPrice * d.Quantity),
SortDirection = ListSortDirection.Descending
};
Also, you can now group objects by the result of an equally complex operation:
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
};
You can use the new Expression Descriptors with either RadGridView, or our QueryableCollectionView, or even the new VirtualQueryableCollectionView.
In case you haven't downloaded our Q3 release yet, do so right away so you can play with all the new yummy bits and supercharge your .NET development even further with another great release from Telerik.
You can find a small sample application demonstrating the power of the new ExpressionDescriptors here. As usual, you can use the same code between our WPF and Silverlight controls.