I want to sort the nested array. In order to sort an AFAIK we need to use ArrayController.
I have an arrays, like so :
[{
id : 1,
voucherno: 1,
details : [{id : 3, srno : 3}, {id :2,srno : 2}, {id : 1, srno : 1}]
},
{
id : 2,
voucherno: 2,
details : [{id : 6, srno : 3}, {id : 5, srno : 1}, {id: 4, srno : 2}]
}]
I want to sort the data of details based on srno. After trying various different things this is what Ihave come up with. But it does not work.
My Model is :
App.Sale = DS.Model.extend({
voucherno : DS.attr('number'),
details : DS.hasMany('Detail',{ async: true })
});
App.Detail = DS.Model.extend({
srno : DS.attr('number')
});
Route :
App.Router.map(function() {
this.resource('sales', {
path: '/'
}, function() {
this.resource('sale', {
path: "/:sale_id"
}, function() {
this.resource('details');
});
});
});
Fiddle is here : JSFiddle
Pl help, I saw all the answers around this, but none of them are working for me.