Group header with converter

6 posts, 0 answers
  1. Sergey Volkov
    Sergey Volkov avatar
    14 posts
    Member since:
    Dec 2009

    Posted 20 Jun 2011 Link to this post

    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)









  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 20 Jun 2011 Link to this post

    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
  3. DevCraft banner
  4. Sergey Volkov
    Sergey Volkov avatar
    14 posts
    Member since:
    Dec 2009

    Posted 20 Jun 2011 Link to this post

    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
  5. Sergey Volkov
    Sergey Volkov avatar
    14 posts
    Member since:
    Dec 2009

    Posted 21 Jun 2011 Link to this post

    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)
  6. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 21 Jun 2011 Link to this post

    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
  7. Sergey Volkov
    Sergey Volkov avatar
    14 posts
    Member since:
    Dec 2009

    Posted 22 Jun 2011 Link to this post

    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.
Back to Top
DevCraft banner