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

Group header with converter

5 Answers 295 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sergey Volkov
Top achievements
Rank 1
Sergey Volkov asked on 20 Jun 2011, 12:27 PM
Hi
In my rad grid view I have the following group header template:
<grid:RadGridView.GroupHeaderTemplate>
    <DataTemplate>
        <TextBlock Text="{Binding Converter={StaticResource GroupHeaderConverter}}"/>
    </DataTemplate>
</grid:RadGridView.GroupHeaderTemplate>

My converter returns string value depending on GroupViewModel

public class GroupHeaderConverter : IValueConverter
{
    #region IValueConverter Members
 
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        GroupViewModel groupViewModel = value as GroupViewModel;
        string formattedValue = GetFormattedValue(groupViewModel);
        int recordsCount = groupViewModel.Group.ItemCount;
        return string.Format("{0}  ({1} item{2})", formattedValue,
            recordsCount, recordsCount == 1 ? string.Empty : "s");
    }

I have one problem with this approach. When rad grid view regroups himself, it doesn't call my Convert method, so I still have old headers (improper items counter or even worse improper formatted value).
How to fix it? (p.s. I need group view model as input converter value, Group/Group.Key isn't enough for me to resolve header value)









5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 20 Jun 2011, 02:46 PM
Hi Sergey Volkov,

I have tested the case and once I group or change the group, the converter is called and the values are displayed correctly. May you take a look at the sample project to verify whether there are no misunderstandings ? 
 

Greetings,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sergey Volkov
Top achievements
Rank 1
answered on 20 Jun 2011, 03:44 PM
The problem occurs when you change column value and automatic regrouping happens (edited record jumps from one group to another). I captured a video, but unfortunately I can't post it here. Try this link
0
Sergey Volkov
Top achievements
Rank 1
answered on 21 Jun 2011, 11:51 AM
I reproduced another issue on the example project you provided
After scrolling grid view up and down and expanding/collapsing group headers they become wrong
See this video  (GK and FW replaced each other)
0
Maya
Telerik team
answered on 21 Jun 2011, 05:59 PM
Hi Sergey Volkov,

The first issue - recalculating the count of the items is expected since the groups are not recreated. What you may try is to define aggregate function directly to the group descriptor:

<telerik:RadGridView Name="playersGrid"
                         ItemsSource="{Binding Players}"                            
                         AutoGenerateColumns="False">
        <telerik:RadGridView.GroupDescriptors>             
            <telerik:GroupDescriptor Member="Position" >
                <telerik:GroupDescriptor.AggregateFunctions>
                    <telerik:CountFunction ResultFormatString="{}{0} items"/>
                </telerik:GroupDescriptor.AggregateFunctions>
            </telerik:GroupDescriptor>
        </telerik:RadGridView.GroupDescriptors>
    </telerik:RadGridView>

Considering the second issue, we will need some time to investigate it. I will get back to you as soon as we can provide any valuable solution. Nevertheless, it is not reproducible when working with an aggregate function.
Please let me know whether the suggested approach meets your requirements. 

Greetings,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sergey Volkov
Top achievements
Rank 1
answered on 22 Jun 2011, 11:54 AM
Thank you. If I needed counter only I would use aggregate function. But I need to format group header itself too (custom date format etc). Solution with converter is more flexible. I hope you will solve these bugs soon.
Tags
GridView
Asked by
Sergey Volkov
Top achievements
Rank 1
Answers by
Maya
Telerik team
Sergey Volkov
Top achievements
Rank 1
Share this question
or