I want to sort embedded records in my content. Initially I had separated the embedded record as an ArrayController and did sorting on it - it was pretty straight forward, but now I am told that I should use just embedded records without ArrayController. I followed http://www.javascriptkit.com/javatutors/arraysort2.shtml to sort the array objects and the content is getting sorted but the view is not getting updated accordingly. My function looks like :
setSort: function (sort) {
var sortedContent = this.get('content.analyticsRunParameters');
sortedContent.sort(function(a, b){
var colA=a.get(sort).toLowerCase(), colB=b.get(sort).toLowerCase();
if (colA < colB) //sort string ascending
return -1;
if (colA > colB)
return 1;
return 0; //default return value (no sorting)
});
this.set('content.analyticsRunParameters',sortedContent);
console.log(sortedContent);//is sorted
console.log(this.get('content.analyticsRunParameters'));//is sorted
}
Is there a way to update the view when my content is sorted? Or using ArrayController the only way around? Thanks.