Sorting on calculated field

Hi,

We have a small tableview in which we would like to show the translated description.
This works ofcourse using a calculated field which returns the

i18n.getI18NMessage(origfield)

But sorting doesn’t work. Apparently we always get the tableview sorted on the origfield
Custom onSort methods don’t work either, i’ve tried :

foundset.sort(calculated_field asc)

and also

controller.sort(calculated_field asc)
foundset.sort(function(a,b) {return i18n.getI18NMessage(a.origfield) > i18n.getI18NMessage(b.origfield);})

but none of these work
Any idea on how to solve this without having to store the calculated field and also while keeping the standard foundset datasource?

Hi,

The sort based on a function should work, the only problem is that a sort only works with the following values to sort:
(-1, 0, 1).

Maybe this will help you to get it working.

foundset.sort(function(a,b) {
     return i18n.getI18NMessage(a.origfield).localeCompare(i18n.getI18NMessage(b.origfield));}