Skip to main content
A newer version of this page is available. .

How to: Implement Custom Grouping

  • 4 minutes to read

This example shows how to group rows using custom rules. When grouping by the 'Unit Price' column, the rows in this column that have values between 0 and 10 should be combined into a single group. Rows whose values fall between 10 and 20 should be combined into another group, etc.

<Window x:Class="DXGrid_CustomGrouping.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
        Title="Window1" Height="300" Width="509">
    <Grid>
        <dxg:GridControl x:Name="grid" 
                         CustomColumnGroup="grid_CustomColumnGroup" 
                         CustomGroupDisplayText="grid_CustomGroupDisplayText"
                         ItemsSource="{Binding ListPerson}"
                         >
            <dxg:GridControl.Columns>
                <dxg:GridColumn FieldName="FirstName" />
                <dxg:GridColumn FieldName="LastName" />
                <dxg:GridColumn FieldName="UnitPrice" SortMode="Custom" GroupIndex="0">
                    <dxg:GridColumn.EditSettings>
                        <dxe:SpinEditSettings DisplayFormat="c2" />
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:TableView AutoWidth="True" />
            </dxg:GridControl.View>
        </dxg:GridControl>
    </Grid>
</Window>