Edit this page

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:RadGridView.Columns>
        <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}" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

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.

Was this article helpful? Yes No

Give article feedback

Tell us how we can improve this article

Dummy