I am displaying a list of results, using a handlebars helper which loops over an array in the controller as below:
{{#each results as |job|}}
{{job-table-row model=job}}
{{/each}}
results: function() {
var searchTerm = this.get('searchTerm'),
results = this.get('content'),
order = this.get('date_ordering'),
status = this.get('Status'),
if (searchTerm) {
results = results.filter(function(item) {
return item.get('name').toLowerCase().indexOf(searchTerm.toLowerCase()) > -1;
});
}
if (status) {
results = results.filter(function(item) {
return (item.get('status') == status);
}
});
}
return results;
}.property('content', 'searchTerm', 'startDate', 'endDate', 'date_ordering', 'Status', 'Platform'),
I would like to add functionality to sort the 'created_at' column when the property 'date-ordering' receives a value:
results: function() {
var searchTerm = this.get('searchTerm'),
results = this.get('content'),
order = this.get('date_ordering'),
status = this.get('Status'),
...
if ((order) && (order ===0)) {
results = results.sort('created_at' sortAscending);
}
else if ((order) && (order ===1)) {
results = results.sort('created_at' sortDescending);
}
});
}
return results;
}.property('content', 'searchTerm', 'startDate', 'endDate', 'date_ordering', 'Status', 'Platform'),
Is it possible to do this in a way similar to the above?
Aucun commentaire:
Enregistrer un commentaire