Welcome to the Xceed Community | Help
Community Search  
More Search Options

Preventing group and sorting

Sort Posts: Previous Next
  •  10-08-2008, 3:54 PM Post no. 28122

    Preventing group and sorting

    The following example demonstrates how to bind a grid to the Orders table and prevent columns from being sorted and reordered and groups from being created or removed. By default, the ShipCountry and ShipCity columns will be sorted, grouped, and fixed.

    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
          xmlns:d="clr-namespace:System.Windows.Data;assembly=PresentationFramework"
          xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase">

      <Grid.Resources>
        <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
                                        Source="{Binding Source={x:Static Application.Current},
                                                          Path=Orders}">

          <xcdg:DataGridCollectionViewSource.SortDescriptions>
            <scm:SortDescription PropertyName="ShipCountry" Direction="Ascending"/>
            <scm:SortDescription PropertyName="ShipCity" Direction="Ascending"/>
          </xcdg:DataGridCollectionViewSource.SortDescriptions>

          <xcdg:DataGridCollectionViewSource.GroupDescriptions>
            <xcdg:DataGridGroupDescription PropertyName="ShipCountry"/>
            <xcdg:DataGridGroupDescription PropertyName="ShipCity"/>
          </xcdg:DataGridCollectionViewSource.GroupDescriptions>
        </xcdg:DataGridCollectionViewSource>

      </Grid.Resources>

      <xcdg:DataGridControl x:Name="OrdersGrid"
                            ItemsSource="{Binding Source={StaticResource cvs_orders}}">     
        <xcdg:DataGridControl.Columns>
          <xcdg:Column FieldName="ShipCountry" VisiblePosition="0"/>
          <xcdg:Column FieldName="ShipCity" VisiblePosition="1"/>
        </xcdg:DataGridControl.Columns>

        <xcdg:DataGridControl.View>
          <xcdg:TableView FixedColumnCount="2" UseDefaultHeadersFooters="False">
            <xcdg:TableView.FixedHeaders>
              <DataTemplate>
                <xcdg:GroupByControl AllowSort="False" AllowGroupingModification="False"/>
              </DataTemplate>
              <DataTemplate>
                <xcdg:ColumnManagerRow AllowSort="False" AllowColumnReorder="False"/>
              </DataTemplate>
            </xcdg:TableView.FixedHeaders>
          </xcdg:TableView>
        </xcdg:DataGridControl.View>
      </xcdg:DataGridControl>
    </Grid>
     

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.