Bjerh
Bjerh

Reputation: 71

EmberJS: Sorting model by property in belongsTo

I have a model with the following list of products...

{
    products: [
        {
            id: 1,
            something: "value",
            properties: {
                name: "Name1"
            }
        },
        {
            id: 2,
            something: "value",
            properties: {
                name: "Name3"
            }
        },
        {
            id: 3,
            something: "value",
            properties: {
                name: "Name2"
            }
        }
    ]
}

If I were to sort on these products by sorting on the "product.properties.name" how would I do that? My first idea was to use the sortableMixin and using the following snippet:

sortProperties: ['properties.name'],
sortAscending: true

But that doesn't really product the result I intended. How should I go about this?

Upvotes: 0

Views: 34

Answers (1)

Deewendra Shrestha
Deewendra Shrestha

Reputation: 2465

SortableMixin is definitely the way to go. Your controller has to extend the mixin and then you can access the arrangedContent like here: http://emberjs.jsbin.com/gagoyeseni/1/

Upvotes: 0

Related Questions