Reputation: 11
I need to sort a material data table only in ascending order when clicking the icon. I don't need to sort it in descending order. How can I achieve it using Angular material data table?
Upvotes: 1
Views: 1312
Reputation: 5742
You can set a default sort option and use sort function on the MatSort api to set that default option. table-sorting-example
defaultSort: MatSortable = {
id: 'defColumnName',
start: 'asc',
disableClear: true
};
then use sort function on MatSort directive:
this.sort.sort(this.defaultSort);
//default sort direction
this.sort.direction = 'asc';
Upvotes: 1