Expression Column

GridViewExpressionColumn derives from GridViewColumn class and allows you to display various calculations in RadGridView itself. GridViewExpressionColumn can be sorted and grouped like any other.

The values displayed in GridViewExpressionColumn will be updated automatically when a concerned property on the data item changes.

Example 1: Define GridViewExpressionColumn in XAML.

<telerik:RadGridView x:Name="RadGridView1" ItemsSource="{Binding Products}" AutoGenerateColumns="False" ColumnWidth="*"> 
        <telerik:GridViewDataColumn Header="Product ID" DataMemberBinding="{Binding ProductID}" /> 
        <telerik:GridViewDataColumn Header="Product name" DataMemberBinding="{Binding ProductName}" /> 
        <telerik:GridViewDataColumn Header="Unit price" DataMemberBinding="{Binding UnitPrice}" DataFormatString="{}{0:C}" /> 
        <telerik:GridViewDataColumn Header="Units in stock" DataMemberBinding="{Binding UnitsInStock}" /> 
        <telerik:GridViewExpressionColumn Header="Total value in stock" UniqueName="TotalValue" DataFormatString="{}{0:C}" /> 
The most important property to be set in code is Expression.

Example 2: Set Expression for GridViewExpressionColumn in code.

Expression<Func<Products, double>> expression = prod => prod.UnitPrice * prod.UnitsInStock; 
GridViewExpressionColumn column = this.RadGridView1.Columns["TotalValue"] as GridViewExpressionColumn; 
column.Expression = expression; 
More information about expressions could be found here.
In this article
Not finding the help you need? Improve this article