Reputation: 249
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
?
Upvotes: 0
Views: 76
Reputation: 966
i know it is not what you want, but after many search i just do this type of sort on the ember
var sortArray = Ember.ArrayProxy.extend(Ember.SortableMixin).create();
sortArray.set("content", []);
sortArray.addObject({"id":10 , "name": 'Built'});
sortArray.addObject({"id":20 , "name": 'Started'});
sortArray.addObject({"id":30 , "name": 'Finished'});
sortArray.set('sortProperties', ["id"]).set("sortAscending", true);
Upvotes: 0