2

I want to sorting on multiple columns in a data table (Angular Material) where next sorting column will give me the result based on previous column sorting.

this.dataSource = new MatTableDataSource(yourData);
this.dataSource.sortingDataAccessor = (item, property) => {
    switch(property) {
        case 'project.isActive': return item.project.isActive;
        case 'project.start': return item.project.start;
        default: return item[property];
    }
};
this.dataSource.sort = sort;

Every time when I am sorting one column, it clears the previously sorted data.

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
  • As you stated, your code does not do what you want it to do. What have you tried so far? What is the exact issue you encountered? – TotallyNewb Nov 22 '22 at 11:19
  • I want to sort on multiple column at a time. E.x. if there are 2 columns like name, value then firstly I want to sort the data based on name column and then sort on value column – Fardin Noman Nov 27 '22 at 04:42

0 Answers0