An Angular library that adds multi-sort capability to the Angular Material table.
- Extend the Angular Material Table to support multiple sorting
- Supports Angular 18 and 19. Supporting all actively supported Angular versions is planned (see #5)
- Batteries included: The repository contains a demo application that can help you integrate the library with your project
- 100% covered by automated unit tests and secured by static code analysis
Prerequisite: You have created an application using a supported version of Angular and Angular Material
- In your Angular application run
npm install ngx-mat-table-multi-sort
to add the library to your dependencies - As this library is using Material, add the following to the
head
element of yourindex.html
:
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet" />
Alternatively, you can also add the following to your angular.json
:
"styles": [
...
"https://fonts.googleapis.com/icon?family=Material+Icons",
...
]
- In the template, replace the
matSort
directive with thematMultiSort
directive. - Also replace the
mat-sort-header
directive with themat-multi-sort-header
directive in the column definitions. - In the component definition use
MatMultiSortTableDataSource<T>
as your datasource type instead ofMatTableDataSource<T>
. - Also change the type of the sorter from
MatSort
toMatMultiSortDirective
- If you are using standalone components, add the
MatMultiSortDirective
andMatMultiSortHeaderComponent
to your component's imports array. Otherwise add them to the NgModule that declares your component. - Done! 🎉
Enjoy multi-sorting your Angular Material data table!
The demo application is hosted on GitHub pages. You can also clone the repository and run the demo locally.
- Clone the repository to your local machine
- Run
npm install
to restore the dependencies - Start the demo application by running
npm run start:demo
- When compilation is completed, the application is running on
http://localhost:4200
The project is subject to the MIT license unless otherwise noted. A copy can be found here.
Please refer to the changelog document or the release notes in GitHub.
We are happy to hear any feedback regarding the library or its implementation, be it critizism, praise or rants. Please create a GitHub issue if you would like to contact us.
We would especially appreciate, if you could report any issues you encounter while using the library. Issues we know about, we can probably fix.
If you want to submit a bug report, please check if the issue you have has already been reported. If you want to contribute additional information to the issue, please add it to the existing issue instead of creating another one. Duplicate issues will take time from bugfixing and thus delay a fix.
While creating a bug report, please make it easy for us to fix it by giving us all the details you have about the issue. Always include the version of the library and a short concise description of the issue. Besides that, there are a few other pieces of information that help tracking down bugs:
- The system environment in which the issue occurred (e.g. node version)
- Some steps to reproduce the issue, e.g. a code snippet
- The expected behaviour and how the failed failed to meet that expectation
- Anything else you think we might need
Please create a GitHub issue!
This library was inspired by the work in ngx-multi-sort-table. While it was created from scratch and is an independent implementation tailored to specific use cases, their ideas and approach provided valuable guidance in its creation. Many thanks for their contributions to the open-source community!
Made with ❤️ by Michaela Andermann and Philip Gerke