This is a migrated thread and some comments may be shown as answers.

GroupHeaderTemplate

7 Answers 829 Views
GridView
This is a migrated thread and some comments may be shown as answers.
gordon
Top achievements
Rank 1
gordon asked on 09 Jan 2018, 05:19 PM

Hi,

I'm trying to use different GroupHeaderTemplates with Converters for the columns in my grid view.  If I apply the template to the entire grid, my converter gets invoked.

           <telerik:RadGridView.GroupHeaderTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Group.Key, Converter={StaticResource IsActiveConverter}}" />
                </DataTemplate>
            </telerik:RadGridView.GroupHeaderTemplate>

 

If I apply the GroupHeaderTemplates to GridViewDataColumn, my converter gets called unless the column had a cell template.  My converter gets called for the followiing:

 

               <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name">

                   <telerik:GridViewDataColumn.GroupHeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Group.Key, Converter={StaticResource IsActiveConverter}}" />

                        </DataTemplate>
                    </telerik:GridViewDataColumn.GroupHeaderTemplate>

            </telerik:GridViewDataColumn>

My converter (IsActiveConverter) does NOT get called for the following.

               <telerik:GridViewDataColumn Width="16" SortMemberPath="FontFormat">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <Image x:Name="TypeIcon" Width="12" Height="12" Style="{StaticResource TypeIconStyle}" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                    <telerik:GridViewDataColumn.GroupHeaderTemplate>
                        <DataTemplate>
                            <Image Source="{Binding Group.Key, Converter={StaticResource IsActiveConverter}}" Height="16" Width="16"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.GroupHeaderTemplate>
                </telerik:GridViewDataColumn>

 

What am I doing wrong?  Thanks.

 

    
 

7 Answers, 1 is accepted

Sort by
0
gordon
Top achievements
Rank 1
answered on 09 Jan 2018, 10:39 PM
Solved.   I was missing GroupMemberPath on my GridViewDataColumn.
0
gordon
Top achievements
Rank 1
answered on 10 Jan 2018, 12:46 AM

I'm still having this issue with one column.  IsActiveConverter.Convert never gets called. 

               <telerik:GridViewDataColumn Width="16" IsSortable="True" SortMemberPath="IsActive" IsGroupable="True" GroupMemberPath="IsActive">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox HorizontalAlignment="Center" IsChecked="{Binding IsActive}" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContentControl}, AncestorLevel=4}, Path= DataContext.ActivateCommand}" CommandParameter="{Binding}" Template="{StaticResource TwoStateActivationTemplate}" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                    <telerik:GridViewDataColumn.GroupHeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Group.Key, Converter={StaticResource IsActiveConverter}}" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.GroupHeaderTemplate>
                </telerik:GridViewDataColumn>

0
Stefan
Telerik team
answered on 12 Jan 2018, 11:18 AM
Hi Gordon,

I tested the behavior of the control and the IValueConverter is triggered as expected on my end. Attached to my reply you can find the sample application I used for testing. Can you please take a look at it? Am I missing something?

Have a nice weekend, Gordon.

Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
gordon
Top achievements
Rank 1
answered on 16 Jan 2018, 04:57 PM

Hi Stefan,

Your sample app isn't working for me, namely the grid does not appear on the main window.  I haven't had a chance to debug yet.  Also, the Libs folder is empty, so I just used the version of the dll's I have, C:\Program Files (x86)\Progress\Telerik UI for WPF R3 2017\Binaries\WPF45.  Perhaps this is the problem.

 

0
gordon
Top achievements
Rank 1
answered on 16 Jan 2018, 10:33 PM

Hi Stefan,

I added the wrong Progress dll's.  I've now added to correct ones, and the sample is working, and the converter gets called when I group the Id column.  I'm handling the grouping differently than you are.  I don't have the grouping panel.  Instead I have a combo box that groups by column.  I followed the ListBox - Grouping and Filtering demo, and applied it to a grid view.

0
gordon
Top achievements
Rank 1
answered on 17 Jan 2018, 04:42 PM

Hi Stefan,

I've modified the sample solution you sent me to match my scenario.  The IsActiveConverter is getting called in this sample, but for some reason not in my solution.  I'll have to figure that out.  I'm having an addition problem that is reproducible in my modified solutions.  I'm getting an exception  when I group using the grouping combobox, but not when dragging a column to the group panel.  The exception gets thrown in MyViewModel.GroupData().  Here's the exception message, "Cannot change or check the contents or Current position of CollectionView while Refresh is being deferred."  Any help is appreciated.  Thanks.

I tried to attach the zipped solution, but your system won't except zip files.  How do I send it to you?

 

0
Stefan
Telerik team
answered on 19 Jan 2018, 01:55 PM
Hello Gordon,

Thank you for the update.

I am sorry to hear that you are still experiencing issues regarding the grouping of the control. I am afraid that I cannot pinpoint the cause for this exception based on the provided information. More information regarding it can be found in the CollectionView.DeferRefresh() throws exception StackOverflow thread. Can you please check it out?

As to attaching archives to a reply, our system does not allow this for forum threads. You can open a new support thread and attach the zip in it.

Have a nice weekend, Gordon.

Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
gordon
Top achievements
Rank 1
Answers by
gordon
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or