Reputation: 1611
My requirement is to sort array using Dynamic property names using EmberJS.
What i have done previously for single column sorting is
ents = @get('acceptedEntities') //get the array
@set('sortAscending', !@get('sortAscending'))
sort_data = ents.sortBy(property_name) //property name is sort order
And what i am looking id
ents = @get('acceptedEntities')
@set('sortAscending', !@get('sortAscending'))
sort_data = ents.sortBy([property_name1, property_name2])
I tried with the above solution but no luck and i here about computed sort and implemented like this
model = @get('acceptedEntities')
sortProperties = [property_name, 'entity_sf_account_name']
sort_data = Ember.computed.sort(model, sortProperties)
But Sorting is not going properly, Please give me suggestions to do this.
i tried this too
sortProperties = ['one:asc', 'two:desc', 'three:asc']
sort_data = Ember.ArrayProxy.createWithMixins(Ember.SortableMixin, {
content: model,
sortProperties: sortProperties
})
the above code works fine for sorting with multiple parameter but when i want sort order its not working properly
Thanks
Upvotes: 0
Views: 310
Reputation: 37389
There are many ways to do this, but I would do it like this:
sortProperties = ['one:asc', 'two:desc', 'three:asc']
sort_data = Ember.ArrayProxy.createWithMixins(Ember.SortableMixin, {
content: model,
sortProperties: sortProperties
})
Upvotes: 1