Hi,
One of the field in my datagrid is number (lets call it Severity, having numbers to represent a severity level). I am ControlTemplating CellValuePresenter of this field to display a color and text instead of number in cells of that field.
When this field is grouped. That number is displayed in the header of group. What should I do to template the header of that group to display color and text instead of that number.
Your help will be much appreciated.
Thanks,
Imad.
Hello Imad,
Thank you for your post. I have been looking into it and I suggest you copy the default Style for the GroupByRecordPresenter from C:\Program Files (x86)\Infragistics\NetAdvantage 2011.2\WPF\DefaultStyles\DataPresenter\DataPresenterGeneric_Express.xaml file and retemplate it so it has an element that will be used to show your color. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Thanks for your reply.
I am already templating GroupByRecordPresenter for displaying buttons in Group header. But couldn't figure out how to change text in header. It seems that "Description" is a dependency property which is actually displayed as the content of Group header. and this "Description"already seems to contains text of that column + summary (i.e., number of items in the group).
Here is the section from GroupByRecordPresenter template where I am displaying buttons and where I did a failed attempt to change text of group header.
Your help will be greatly appreciated.
<!-- Record content site --> <!-- AS 1/27/09 NA 2009 Vol 1 - Set RenderTransform for fixed fields --> <Grid x:Name="PART_RecordContentSite" RenderTransform="{TemplateBinding FixedNearElementTransform}" Margin="0" Grid.Row="1" Grid.Column="1" Visibility="Collapsed"> <!-- Background Bar --> <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" RenderTransformOrigin="0.5,0.5" CornerRadius="2,2,2,2" SnapsToDevicePixels="True" Background="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelBackground}}"> <Grid Margin="0,0,0,0" Width="Auto" Height="Auto"> <Rectangle Stroke="#44000000" StrokeThickness="1" RadiusX="1.55015910897703" RadiusY="1.55015910897703" Fill="Transparent"/> <Rectangle Margin="1" Stroke="#44FFFFFF" StrokeThickness="1" RadiusX="0.550159108977027" RadiusY="0.550159108977027" Fill="Transparent"/> </Grid> </Border> <!-- End Added 8/1/2006 GH --> <!-- End Background Bar --> <Border x:Name="highlight" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" CornerRadius="2,2,2,2" Background="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelHighlight}}"> <Grid Margin="0,0,0,0" Width="Auto" Height="Auto"> <Rectangle Stroke="#44000000" StrokeThickness="1" RadiusX="1.55015910897703" RadiusY="1.55015910897703" Fill="Transparent"/> <Rectangle Margin="1" Stroke="#44FFFFFF" StrokeThickness="1" RadiusX="0.550159108977027" RadiusY="0.550159108977027" Fill="Transparent"/> </Grid> </Border> <!-- End Add 8/1/2006 GH--> <!-- Label Text --> <!-- SSP 4/3/08 - Summaries Functionality Enclosed the existing ContentControl node into a Grid and added GroupBySummariesPresenter node. --> <!--Section where buttons are added in group header--> <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch"> <StackPanel Orientation="Horizontal" Width="Auto" Margin="3,0,0,0" > <StackPanel.CommandBindings> <!-- Listen for our custom GroupAButtonPressed command. --> <CommandBinding Command="local:MyDataGrid.GroupAckButtonPressed" CanExecute="GroupAButtonPressed_CanExecute" Executed="GroupAButtonPressed_Executed" /> <!-- Listen for our custom GroupBButtonPressed command. --> <CommandBinding Command="local:MyDataGrid.GroupBButtonPressed" CanExecute="GroupClearBPressed_CanExecute" Executed="GroupBButtonPressed_Executed" /> <!-- Listen for our custom GroupBButtonPressed command. --> <CommandBinding Command="local:MyDataGrid.GroupCButtonPressed" CanExecute="GroupCButtonPressed_CanExecute" Executed="GroupCButtonPressed_Executed" /> </StackPanel.CommandBindings> <Button Command="local:MyDataGrid.GroupAButtonPressed" CommandParameter="{Binding Path=., RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:GroupByRecordPresenter}}}" Width="24" Height="24" AutomationProperties.AutomationId="{Binding Path=Description, RelativeSource={RelativeSource TemplatedParent}, StringFormat='GroupAButton{0}'}" Style="{StaticResource ActiveButtonsCollapseStyle}" ToolTip="{DynamicResource Viewer_AAGroupTooltip}"> <Image Source="{DynamicResource _AGroup}" HorizontalAlignment="Left" Stretch="Uniform" Width="Auto" Height="Auto" /> </Button> <Button Command="local:MyDataGrid.GroupCButtonPressed" CommandParameter="{Binding Path=., RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:GroupByRecordPresenter}}}" Width="24" Height="24" AutomationProperties.AutomationId="{Binding Path=Description, RelativeSource={RelativeSource TemplatedParent}, StringFormat='GroupCButton{0}'}" Style="{StaticResource ActiveButtonsCollapseStyle}" ToolTip="{DynamicResource Viewer_CGroupTooltip}"> <Image Source="{DynamicResource _CGroup}" HorizontalAlignment="Left" Stretch="Uniform" Width="Auto" Height="Auto" /> </Button> <Button Command="local:MyDataGrid.BButtonPressed" CommandParameter="{Binding Path=., RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:GroupByRecordPresenter}}}" Width="24" Height="24" AutomationProperties.AutomationId="{Binding Path=Description, RelativeSource={RelativeSource TemplatedParent}, StringFormat='GroupBButton{0}'}" Style="{StaticResource BButtonsCollapseStyle}" ToolTip="{DynamicResource Viewer_BGroupTooltip}"> <Image Source="{DynamicResource _BGroup}" HorizontalAlignment="Left" Stretch="Uniform" Width="Auto" Height="Auto" /> </Button> </StackPanel> <StackPanel Orientation="Vertical" Width="Auto"> <!--<Ellipse Height="15" Width="15" Margin="0,0,3,0" VerticalAlignment="Center" Stroke="LightGray" Fill="{Binding Path=Description, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ValueToBrushConverter}}"> <Ellipse.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding Path=Ellipse.Fill}" Value="{x:Null}"> <Setter Property="Ellipse.Visibility" Value="Collapsed"/> </DataTrigger> </Style.Triggers> </Style> </Ellipse.Style> </Ellipse>--> <ContentControl Style="{StaticResource LabelContentStyle}" Content="{Binding Path=Description, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"> </ContentControl> <!-- SSP 4/3/08 - Summaries Functionality --> <!-- AS 1/27/09 NA 2009 Vol 1 - Set RenderTransform for fixed fields --> <igDP:GroupBySummariesPresenter RenderTransform="{TemplateBinding ScrollableElementTransform}" HorizontalAlignment="Left" x:Name="GroupBySummariesPresenter" Visibility="Collapsed" GroupByRecord="{TemplateBinding Record}"/> </StackPanel> </StackPanel> </Grid>
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well. Also I will look at your other forum thraed as soon as possible.
Thanks again.
Hey Stefan can you please look into this (http://community.infragistics.com/forums/p/68353/347293.aspx#347293) issue as well.
Kudos to Stefan, thanks man it worked like a charm. My bad that I couldn't figure out how to do that.
Thanks again,
I apologize for the late response. I have been looking into your requirement and I modified the sample I sent you before, so now it works as you want. Please note that the approach I gave you is a basic approach, which you can follow to make a custom implementation of the thing you want to achieve, since there isn’t any built in functionality for it.
Hope this helps you.
I tried your solution. It fixes that problem but now it creates another problem.
Item count in the summary of header should update when new items are added but its not updating at all. When I expanded the group, new item was there in the list.
It has already taken too much time. And your help is also slow. I'll be grateful for a solution that doesn't break anything else.
Thanks,Imad.