Results 1 to 6 of 6

Thread: Custom sorterFn not allowed in grouper

    Success! Looks like we've fixed this one. According to our records the fix was applied for DSGNR-8067 in Architect 4.2.3.
  1. #1
    Sencha User
    Join Date
    May 2010
    Posts
    151

    Default Custom sorterFn not allowed in grouper

    In Architect 4.2.2 b282 with ExtJS GPL 6.0.1 I'm not allowed to add a sorterFn on a grouper.

    I'm trying to sort a store based on the summary of the grouping field but it's not working from Architect.

    In Architect it's only allowed to have a sortFn directly under the store which isn't working as expected.
    If I manually edit the .js-file and move the sortFn() to the grouper and build it manually it works as expects, but as soon as I open the project in Architect it get's moved out from the grouper and stops working.

    This works (manually edited)
    Code:
    Ext.define('Archive.store.Games', {
        extend: 'Ext.data.Store',
    
        requires: [
            'Archive.model.Game',
            'Ext.data.proxy.Rest',
            'Ext.data.reader.Json',
            'Ext.data.writer.Json',
            'Ext.util.Grouper'
        ],
    
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                storeId: 'Games',
                model: 'Archive.model.Game',
                proxy: {
                    type: 'rest',
                    batchActions: true,
                    extraParams: {
                        otype: 'user',
                        recursive: false
                    },
                    url: '/api/v1/archive/games.php',
                    appendId: false,
                    reader: {
                        type: 'json'
                    },
                    writer: {
                        type: 'json'
                    }
                },
                grouper: {
                    property: 'playerName',
                    sorterFn: function(first, second) {
    var suma=0; me.each(function (rec) { suma += rec.data.playerName === first.data.playerName ? rec.data.score:0; });
    var sumb=0; me.each(function (rec) { sumb += rec.data.playerName === second.data.playerName ? rec.data.score:0; });
    
                        if (suma > sumb) return 1;
                        if (suma < sumb) return -1;
                        return 0;
                    }
                }
            }, cfg)]);
        }
    
    });
    

    This is the Architect version which dosen't work
    Code:
    Ext.define('Archive.store.Games', {
        extend: 'Ext.data.Store',
    
    
        requires: [
            'Archive.model.Game',
            'Ext.data.proxy.Rest',
            'Ext.data.reader.Json',
            'Ext.data.writer.Json',
            'Ext.util.Grouper'
        ],
    
    
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                storeId: 'Games',
                model: 'Archive.model.Game',
                proxy: {
                    type: 'rest',
                    batchActions: true,
                    extraParams: {
                        otype: 'user',
                        recursive: false
                    },
                    url: '/api/v1/archive/games.php',
                    appendId: false,
                    reader: {
                        type: 'json'
                    },
                    writer: {
                        type: 'json'
                    }
                },
                sorters: {
                    sorterFn: function(first, second) {
                        var suma=0; me.each(function (rec) { suma += rec.data.playerName === first.data.playerName ? rec.data.score:0; });
                        var sumb=0; me.each(function (rec) { sumb += rec.data.playerName === second.data.playerName ? rec.data.score:0; });
    
    
                        if (suma > sumb) return 1;
                        if (suma < sumb) return -1;
                        return 0;
                    }
                },
                grouper: {
                    property: 'playerName'
                }
            }, cfg)]);
        }
    });

  2. #2
    Sencha User
    Join Date
    Sep 2014
    Location
    Central Europe
    Posts
    795

    Default

    Thanks for the report we will investigate more. In the meantime you can use this workaround https://www.youtube.com/watch?v=lLmLD3unWO4

  3. #3
    Sencha User
    Join Date
    May 2010
    Posts
    151

    Default

    Thanks, can I download Architect 4.2.3 somewhere?

  4. #4
    Sencha User
    Join Date
    Sep 2014
    Location
    Central Europe
    Posts
    795

    Default

    Hi

    Sorry the 4.2.3 is not yet out and there are no beta builds on the support portal. But we are planning to add "beta" versions to support portal soon.

    Regards
    Petr

  5. #5
    Sencha User
    Join Date
    May 2010
    Posts
    151

    Default

    To bad, when can we expect a public release?

  6. #6
    Sencha User
    Join Date
    Sep 2014
    Location
    Central Europe
    Posts
    795

    Default

    There is not a firm date yet but hopefully it could be by the end of this month.

Similar Threads

  1. [OPEN] Grid Grouping Issue (2+3) : sortProperty and sorterFn
    By Moritori in forum Ext 5: Bugs
    Replies: 5
    Last Post: 29 Sep 2014, 1:35 PM
  2. Replies: 1
    Last Post: 16 Jun 2014, 1:55 PM
  3. Trying to use custom grouper on store
    By jclark42796 in forum Ext: Q&A
    Replies: 5
    Last Post: 4 May 2012, 7:56 AM

Posting Permissions

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