I would like to sort a table by column. This works as expected but the icons for ascending is displayed at every 3rd click.
This is my code (working with ember 2.14):
export default Ember.Component.extend({
model: null,
table: null,
sortProps: ['lastName:asc'],
sortedPeople: computed.sort('model', 'sortProps'),
columns: computed(function() {
return [{
label: 'Vorname',
valuePath: 'firstName',
}, {
label: 'Nachname',
valuePath: 'lastName',
}];
}),
table: computed('sortedPeople', function() {
return new Table(this.get('columns'), this.get('sortedPeople'));
}),
actions: {
onColumnClick(column){
let dir = column.ascending ? ':asc' : ':desc';
this.setProperties({
sortProps: [ column.get('valuePath') + dir ]
});
}
)};
Aucun commentaire:
Enregistrer un commentaire