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

Is it possible to hide the group member name in the group caption?

4 Answers 86 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Kjell asked on 20 Apr 2011, 07:48 PM
I am following this example:

http://www.telerik.com/help/wpf/gridview-grouping-aggregates.html

The first group caption is:

"Argentina  Entries count: 1  First entry:  Patricio Simpson"

Is it possible not to show the "Argentina" part? So it's just  "Entries count: 1  First entry:  Patricio Simpson"

Secondly, but not as important, would be cool if instead of the FirstFunction just calling the "ToString()" method, if was possible to specify a field in your business object to display. 

4 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 21 Apr 2011, 07:58 AM
Hello Kjell,

 

You may achieve the desired result by predefining the GroupHeaderTemplate at a RadGridView level and assign it to an empty DataTemplate, as shown below:

<telerik:RadGridView ItemsSource="{Binding Collection}">
        <telerik:RadGridView.GroupHeaderTemplate>
            <DataTemplate>
                </DataTemplate>
            </telerik:RadGridView.GroupHeaderTemplate>
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn Header="P1" DataMemberBinding="{Binding Property1}">
                <telerik:GridViewDataColumn.AggregateFunctions>
                    <telerik:CountFunction Caption="Count:"/>
                    </telerik:GridViewDataColumn.AggregateFunctions>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn Header="P1" DataMemberBinding="{Binding Property2}">
                <telerik:GridViewDataColumn.AggregateFunctions>
                    <telerik:CountFunction Caption="Count:"/>
                    </telerik:GridViewDataColumn.AggregateFunctions>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn Header="P1" DataMemberBinding="{Binding Property1}">
                <telerik:GridViewDataColumn.AggregateFunctions>
                    <telerik:CountFunction Caption="Count:"/>
                    </telerik:GridViewDataColumn.AggregateFunctions>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>


Please let me know how this works for you!

Greetings,
Vanya Pavlova
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
Kjell
Top achievements
Rank 1
answered on 05 May 2011, 09:58 PM
Thanks, your answer got me down the right path.  My ultimate goal was to be able to group on a datetime, but then format the datetime to my liking in the group row.  I setup the template as you described, but I bound it to the group.key.  Then added the following handler for the textblock loaded event:

private void TextBlock_Loaded(object sender, RoutedEventArgs e)
  {
      TextBlock block = (TextBlock)sender;
      string text = block.Text;
      DateTime dt = System.Convert.ToDateTime(text);
      block.Text = dt.ToString("M/d/yy");
  }


Probably a bit goofy but gets the job done.
0
Kjell
Top achievements
Rank 1
answered on 05 May 2011, 10:50 PM
Ok one more update in case anyone else runs into this.  All I really needed to do is set

DataFormatString

 

 

="{}{0:d}"

 


So I ended up not using my previous solution.  DateFormatString will cover both grouping and filtering.
0
Kjell
Top achievements
Rank 1
answered on 08 May 2011, 08:10 PM
Another correct, setting the dateformat doesn't work if you have blank dates because they will show as "1/1/001".  I went back to my original solution so I could have more control over what is shown.

Now sure how I am going to deal with the filtering though.
Tags
GridView
Asked by
Kjell
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Kjell
Top achievements
Rank 1
Share this question
or