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

Show only first letter in Group Header

1 Answer 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Inger Marie
Top achievements
Rank 1
Inger Marie asked on 02 Sep 2014, 08:47 AM
I have a GridView which contains a name column - and the name may be null or " " or "" or a real name.

Ex:
Name1: null
Name2: " "
Name3: ""
Name4: "Obama"
Name5: "obama"
Name6: " obama" (should be grouped with Obama and not with "")

In the group header I would like to group by the names first letter - or "" if there String.IsNullOrWhiteSpace is true. And I would like the group header to ignore the case of the first letter.
There are other columns in the GridView which I do not want grouped like this.

I have done this:
 GroupMemberPath="Entity.Name[0]"

But that leaves an ugly square in the header if the name is null - (and " " and "" are grouped in two different groups. So is "Obama" and "obama" and " obama").

I have a quite a few of these name-columns around in my program, so I would like an elegant, reusable solution :ΓΈ) What I really need is a way to add a Converter to the group binding.

Normally I would use a converter, but there does not seem to be a way to add a converter to the groupmemberpath (?)
There is a GroupHeaderFormatString; but I have failed to find a way to get {}{0:<something>} to return the first letter.
The type of Name is String. I really do not want to change this so adding a FirstLetter-property is not a solution either.
Seems like adding a GroupHeaderTempate will only affect the text in the group header. It will not allow me to group "Obama" and "obama" in the same group.

Is there a solution to this?
Thanks


1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 02 Sep 2014, 02:52 PM
Hello,

In order to define the way the grouping to be applied, you can check our online documentation on Using generic GroupDescriptor.

You can also check this forum thread where a similar question was already discussed.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Inger Marie
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or