mardi 15 mars 2016

Ember - How to sort by transform?

I am trying to sort a model in Ember by a field that has a transform. The original field is an IntegerField (served by an API), which is ordered appropriately. When the field is deserialized by the transform into the string representation, ember sorts by the string, as opposed to the original order.

For instance, if this is the deserialization:

{
10: 'Built',
20: 'Started',
30: 'Finished',
};

I want this to appear as Built, Started, Finished when sorted, according to the original enum. However, it will actually be sorted as Built, Finished, Started, per the alphabetized strings.

Is this possible when using Ember.computed.sort?

Aucun commentaire:

Enregistrer un commentaire