Hybrid View

  1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    10
    Vote Rating
    0
    hessius is on a distinguished road

      0  

    Default Unanswered: Sort, group list in Sencha Touch 2.1 by first letter after hyphen if present

    Unanswered: Sort, group list in Sencha Touch 2.1 by first letter after hyphen if present


    I have dataset to be used in a list using Sencha Touch 2.1 in which most items begin with a prefix (E.g. P-, S-, CSV- etc.). Some, however, do not.
    The prefix is not relevant for sorting and grouping the list (as the prefix is not what users will be looking for). If all items had prefixes and all prefixes were single letters I would just sort by third letter. As this is not the case I really have no idea how to continue.
    Thus I want to set up a conditional grouping and sorting function along the lines of: If {name} contains hyphen: sort/group by first letter after first hyphen, else: sort by first letter
    Also, some of the names will be identical without the prefix (e.g P-Albumin, U-Albumin) if the rest of the string is identical I'd want the rows with "Albumin" to be sorted their prefixes. Also, even with prefixes some strings would be the same and another field e.g. "age" would differ so
    Code:
    { name: 'P-Albumin', age: '40 - 50' },
    { name: 'P-Albumin', age: '20 - 30' },
    { name: 'CSV-Albumin', age: '30' },
    { name: 'ASAT', age: '30'},
    Would be grouped together under the letter A, and sorted so that the row with age equalling 20 - 30 would precede the one equalling 40 - 50, and the row with the prefix CSV- in turn would precede them both and ASAT remaining last.
    I appreciate any tips, pointers, help, advice I can get.

  2. #2
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    714
    Vote Rating
    42
    Answers
    41
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

  3. #3
    Sencha User
    Join Date
    Jan 2013
    Posts
    10
    Vote Rating
    0
    hessius is on a distinguished road

      0  

    Default


    Yes, the problem was writing the actual function.

    I posted this over at StackOverflow as well and it has now been solved: http://stackoverflow.com/questions/1...hen-if-present

Thread Participants: 1

Tags for this Thread