can anyone tell me how to extract the mat-sort-header functionality from the headers into a menu.
I want to open a menu when I click on one of the header. Within this menu I want to use the matSort functionality.
In fact, I want to trigger the matSortChange event
You're asking about "contextual menu" and "mannage mat-sort". It's a broad question and really I don't know how answer, so a brief data
If you see the source of matSort. You can "override" the method sort.
You can use some like
So you can choose "not emit the change" or emit in a contextual menu.
For contextual menu you can use cdk-overlay. It's not well documented, but if you want an example, sometime ago I wrote this SO.
Another option is that each td of your header was a mat-menu
NOTE: I don't know how many is your knowledge in Angular, so it's possible this answer don't help you so much. Give us more data
Update well, we has all necesary with this data, so go on!
First we "override" the sort function to do nothing and create a new function to make the sort
Then use mat-menu in the th. So our th will be like
Finally we need some .css to "remove" the arrow that material add. In styles.css
And to beauty our menu in component.css
the result in this stackblitz