Show only first letter in Group Header

2 posts, 0 answers
  1. Inger Marie
    Inger Marie avatar
    86 posts
    Member since:
    Nov 2010

    Posted 02 Sep 2014 Link to this post

    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


  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 02 Sep 2014 Link to this post

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