mercredi 21 mai 2014

GridPanel - Sort by GroupingSummary

I am having an issue where I setup a sorting function in my store, but what happens is that it prefers the higher value, not the summarized higher value.

Groupers in my store:



Code:




groupers: [ {
property: 'groupName',
sorterFn: function(o1, o2)
{
if (o1 == o2) return 0;
if (o1 > o2) return -1;
if (o1 < o2) return 1;
}
}
]

What occurs is the following:

I have lets say 5 records belonging to 2 groups:



  1. group 'abc' has a 2 records, one has a 'number' value of 5, the other has a number value of 5000 (number total: 5005)

  2. group 'bcd' has 3 records, each record has a 'number' value of 2000 (number total: 6000)


What happens is that it sorts by the highest 'number', so group 'abc' is on top, while 'bcd' is below, even though 'bcd' has a bigger total.

Does anyone know how to fix this issue? Or how I should be doing this properly?


Any help is greatly appreciated. Thanks!





Aucun commentaire:

Enregistrer un commentaire