PDA

View Full Version : [FIXED] Custom sorterFn not allowed in grouper



ZyBeR
13 Aug 2017, 11:35 PM
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)


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


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)]);
}
});

petr.vecera
15 Aug 2017, 4:04 AM
Thanks for the report we will investigate more. In the meantime you can use this workaround https://www.youtube.com/watch?v=lLmLD3unWO4

ZyBeR
15 Aug 2017, 7:36 AM
Thanks, can I download Architect 4.2.3 somewhere?

petr.vecera
15 Aug 2017, 9:18 AM
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

ZyBeR
15 Aug 2017, 12:20 PM
To bad, when can we expect a public release?

petr.vecera
16 Aug 2017, 2:44 AM
There is not a firm date yet but hopefully it could be by the end of this month.