1, 2, 3, etc. showing as separate headers

4 posts, 1 answers
  1. Paras
    Paras avatar
    11 posts
    Member since:
    May 2011

    Posted 20 Jun 2012 Link to this post

    Hi,

    If I have a list bound to the JumpList which has various items starting with different numbers, then the jump list grouping is shown with different numbered headers instead of all of them combined under #.

    I could reproduce this easily with the sample provided as well by adding values starting with different numbers to the sample data file.

    Please see the attached screenshot for details. How do I combine all the values starting with numbers under one group '#'?

    Regards,
    Paras Wadehra
    Twitter: @ParasWadehra
  2. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 20 Jun 2012 Link to this post

    Hi Paras,

    Thanks for writing and for your question.

    This can be easily done by returning the "#" symbol as a group key for all items that start with a number. You can do this in the group key selector unless you are using a PropertyGroupDescriptor instead of generic group descriptor.

    Let me know if you need further assistance.

    Kind regards,
    Deyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Paras
    Paras avatar
    11 posts
    Member since:
    May 2011

    Posted 20 Jun 2012 Link to this post

    Hi Deyan,

    I have the following code in my project. Some of the contacts have names starting with different numbers in the list. How do I combine them into one group # from here?

    GenericGroupDescriptor<stringstring> groupByFirstName = new GenericGroupDescriptor<stringstring>(contact => contact.Substring(0, 1).ToLower());
    this.jumpList.GroupDescriptors.Add(groupByFirstName);
    

    Thanx.
  5. Answer
    Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 21 Jun 2012 Link to this post

    Hello Paras,

    You just need to check whether the first character of the group key is a number. If yes, you return the '#'  symbol in the group descriptor instead of the number itself. If the first character is not a number, you just return the character itself. As simple as that:

    GenericGroupDescriptor<string, string> groupByFirstName = new GenericGroupDescriptor<string, string>(
    (string key) =>
    {
        char firstCharacter = key[0];
        if (char.IsDigit(firstCharacter))
        {
            return "#";
        }
        return firstCharacter.ToString().ToLower();
    }
    );
    this.jumpList.GroupDescriptors.Add(groupByFirstName);

    I hope this helps.

    Regards,
    Deyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top