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

How to use the GroupValueTemplate and GroupValueTemplateSelector?

Sort Posts: Previous Next
  •  02-09-2011, 9:12 AM Post no. 29784

    How to use the GroupValueTemplate and GroupValueTemplateSelector?

    I am trying to implement a dynamic way of displaying group information based on varying values.  Here is my setup:

    Grid:
    <xcdg:DataGridControl x:Name="datagrid" ItemScrollingBehavior="Immediate" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="2" Margin="0,10,0,0" FontSize="11" FontFamily="Arial" BorderThickness="0,0,0,0" Background="{x:Null}" AutoCreateColumns="False" xcdg:GroupLevelIndicatorPane.ShowIndicators="False" xcdg:GroupLevelIndicatorPane.ShowVerticalBorder="False" EditTriggers="None" VerticalContentAlignment="Center" NavigationBehavior="RowOnly" SelectionMode="Single" BorderBrush="{x:Null}" HideSelection="False" ScrollViewer.VerticalScrollBarVisibility="Hidden" >
    <xcdg:DataGridControl.Resources>
    <ResourceDictionary>
    <Style x:Key="GridPrintMargins" TargetType="{x:Type xcdg:DataGridPageControl}">
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="{x:Type xcdg:DataGridPageControl}">
    <DockPanel>
    <StackPanel xcdg:DataGridPageControl.IsPageHeadersHost="True"
    DockPanel.Dock="Top"/>
    <StackPanel xcdg:DataGridPageControl.IsPageFootersHost="True"
    DockPanel.Dock="Bottom"/>
    <Border Margin="25,0,25,0"
    xcdg:DataGridPageControl.IsDataGridHost="True"
    DockPanel.Dock="Top"/>
    </DockPanel>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    <DataTemplate x:Key="CassetteGroupHeaderRow" DataType="{x:Type xcdg:Group}">
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
    <TextBlock Text="{Binding CreatedOn}" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FontColorFormBlueLabel}" HorizontalAlignment="Center"/>
    <TextBlock Text="(" FontFamily="Arial" Margin="5,0,0,0" FontSize="14" Foreground="{DynamicResource FontColorFormBlueLabel}" HorizontalAlignment="Center"/>
    <TextBlock Text="{Binding CreatedBy}" FontSize="14" Foreground="{DynamicResource FontColorFormBlueLabel}" HorizontalAlignment="Center"/>
    <TextBlock Text=")" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FontColorFormBlueLabel}" HorizontalAlignment="Center"/>
    <TextBlock Text="Remaining Cassette(s):" Margin="15,2,0,0" FontFamily="Arial" FontSize="12" Foreground="{DynamicResource GlyphBrush}" HorizontalAlignment="Center"/>
    <TextBlock Text="{Binding NumberRemaining}" Margin="5,2,0,0" FontFamily="Arial" FontSize="12" Foreground="{DynamicResource GlyphBrush}" HorizontalAlignment="Center"/>
    <TextBlock Text="On Order Cassette(s):" Margin="15,2,0,0" FontFamily="Arial" FontSize="12" Foreground="{DynamicResource GlyphBrush}" HorizontalAlignment="Center"/>
    <TextBlock Text="{Binding Path=NumberOrdered}" Margin="5,2,0,0" FontFamily="Arial" FontSize="12" Foreground="{DynamicResource GlyphBrush}" HorizontalAlignment="Center"/>
    </StackPanel>
    </DataTemplate>
    <DataTemplate x:Key="IVGroupHeaderRow" DataType="{x:Type xcdg:Group}">
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
    <TextBlock Text="{Binding Value}" Visibility="Collapsed"/>
    <TextBlock Text="{Binding CreatedOn}" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FontColorFormBlueLabel}" HorizontalAlignment="Center"/>
    <TextBlock Text="(" FontFamily="Arial" Margin="5,0,0,0" FontSize="14" Foreground="{DynamicResource FontColorFormBlueLabel}" HorizontalAlignment="Center"/>
    <TextBlock Text="{Binding CreatedBy}" FontSize="14" Foreground="{DynamicResource FontColorFormBlueLabel}" HorizontalAlignment="Center"/>
    <TextBlock Text=")" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FontColorFormBlueLabel}" HorizontalAlignment="Center"/>
    <TextBlock Text=" - Remaining IV Bag(s) : " Margin="15,2,0,0" FontFamily="Arial" FontSize="12" Foreground="{DynamicResource GlyphBrush}" HorizontalAlignment="Center"/>
    <TextBlock Text="{Binding NumberRemaining}" Margin="5,2,0,0" FontFamily="Arial" FontSize="12" Foreground="{DynamicResource GlyphBrush}" HorizontalAlignment="Center"/>
    <TextBlock Text=" - On Order IV Bag(s) : " Margin="15,2,0,0" FontFamily="Arial" FontSize="12" Foreground="{DynamicResource GlyphBrush}" HorizontalAlignment="Center"/>
    <TextBlock Text="{Binding NumberOrdered}" Margin="5,2,0,0" FontFamily="Arial" FontSize="12" Foreground="{DynamicResource GlyphBrush}" HorizontalAlignment="Center"/>
    <TextBlock Text="{Binding Items.Count}" Visibility="Collapsed"/>
    </StackPanel>
    </DataTemplate>
    </ResourceDictionary>
    </xcdg:DataGridControl.Resources>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column x:Name="IDColumn" FieldName="GroupDetail" GroupValueTemplateSelector="{StaticResource medAdminGroupTemplateSelector}" ReadOnly="True" Width="0" Visible="False">
    </xcdg:Column>
    <!-- OTHER COLUMNS --> 
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>

    Converter:
        public class MedAdminGroupTemplateSelector : DataTemplateSelector
        {
            public override DataTemplate SelectTemplate(object item, DependencyObject container)
            {
                ContentPresenter pres = container as ContentPresenter;
                DataTemplate dataTemplate = null;
                MedAdminGroupDetail detail = (MedAdminGroupDetail)item;
               
                switch(detail.Route) {
                    case "IV":
                        dataTemplate = pres.FindResource("IVGroupHeaderRow") as DataTemplate;
                        break;
                    case "CASSETTE":
                        dataTemplate = pres.FindResource("CassetteGroupHeaderRow") as DataTemplate;
                        break;
                }
                return dataTemplate;
            }
        }

     

    So far everything seems ok except for one major problem, the group appears as follows:

    : [GroupValueTemplate] (# items)

    where the [GroupValueTemplate] is provided by the GroupValueTemplateSelector.

     How do I fix this such that the : and (# items) do not appear, such that the group would only display the following:

    [GroupValueTemplate] 

  •  02-09-2011, 12:44 PM Post no. 29788 in reply to 29784

    Re: How to use the GroupValueTemplate and GroupValueTemplateSelector?

    Hi Michael, 

     To remove the column title in the group header of a specific field, you could use the following implicit DataTemplate with a DataTrigger on the Title that would set the visibility of this title to collapsed.

     

    You can refer to the following forum post for an answer:

    http://xceed.com/CS/forums/post/21178.aspx 


    Best Regards,

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