Results 1 to 6 of 6

Thread: Groupers with sortProperty are broken

    Success! Looks like we've fixed this one. According to our records the fix was applied for a bug in our system in a recent build.
  1. #1
    Sencha User
    Join Date
    Aug 2014
    Posts
    21

    Default Groupers with sortProperty are broken

    Somehow grouping just won't work with sorting.

    I'm trying to make a grid grouped by an enumeration called "Status". I started by using the "groupField" property, coupled with the grouping feature. My problem is that I'm trying to sort the groups by a custom function.

    1. I put everything in a grouper property, and I tried using the sorterFn function to specify a custom comparison. For some reason, "sorterFn" is not available in the list of properties of the architect for a grouper (even though "groupFn" is ironically there). The sorting didn't work even though my custom function was called and returning the right values (!)

    2. I figured it would be a pain to debug it this way, so I added a virtual field in my model which is a rank (basically the same way my sorterFn was done):

    Code:
        fields: [
            {
                type: 'string',
                name: 'Status'
            },
            {
                type: 'int',
                convert: function(v, rec) {
                    var statuses = {
                        'Open': 10,
                        'Planned': 20,
                        'Delivered': 30,
                        'Received': 40,
                        'Rejected': 50
                    };
                    return statuses[rec.data.Status] || null;
                },
                name: 'Status_Id'
            }
        ]

    And my grouper obviously looks like this:

    Code:
                grouper: {
                    property: 'Status',
                    sortProperty: 'Status_Id'
                }
    Producing the following result:

    SCIT_Sorting_Bug.png


    Awesome, it's ignoring my sortProperty and sorting the groups alphabetically.

    3. I tried using sorter but it sorts the rows inside a given group and not the groups themselves.

    4. I tested using Status_Id as the grouping properties. The groups were in the right orders (the numeric order was expected to be sort properly) but that's not what I want since I need titles for the groups which are my statuses (e.g. Status: Planned on the screenshot). Ideally, I shouldn't even have to create a Status_Id field, if sorterFn worked as intended. But it doesn't, and neither does sortProperty.

    So I have a feeling no matter what sorting method I try to use, the grouper will be sorted alphabetically afterwards.

    What's wrong with sorting groupers?

    I'm using extjs-5.0.1.

    Thanks in advance!

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the report. This definitely seems like a bug. Can you please post a test case which reproduces the issue?
    https://fiddle.sencha.com/#home

  3. #3
    Sencha User
    Join Date
    Aug 2014
    Posts
    21

    Default

    Hey Gary, thank you for your time. https://fiddle.sencha.com/?fiddle=gud#fiddle/gud The grouping works in 5.1.0 and not in 5.0.1! Which is pretty bad considering the Architect is only available for 5.0.

  4. #4
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Glad to hear (and confirm) it's been fixed already.

    Regarding Architect, it sounds from these posts that we can expect a version very soon that supports 5.1.0.
    http://www.sencha.com/forum/showthread.php?295925#4
    http://www.sencha.com/forum/showthread.php?297031#2

  5. #5
    Sencha User
    Join Date
    Aug 2014
    Posts
    21

    Default

    I'm really glad you don't have to work on this issue. Still inconvenient for me in the meantime.

  6. #6
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •