daniel-nagy / md-data-table

Material Design Data Table for Angular Material
MIT License
1.9k stars 520 forks source link

Add ability to remove order by value #557

Open cthurston opened 7 years ago

cthurston commented 7 years ago

Once a table header with md-order-by is clicked, the table component does not offer a way to remove/reset the order.

One idea is that if the sort is desc, clicking it will set the md-order value to null or empty string. This would allow instead of toggling it would cycle between 3 values up, down, and nothing.

Another idea is add a small x next to the arrow, indicating that it can be removed.

cthurston commented 7 years ago

In the setOrder function this is what I'm thinking. I tried to create a pull request but had tab/spaces issues.

       if(headCtrl.order === '-' + scope.orderBy){
          headCtrl.order = '';
        } else if(isActive()) {
          headCtrl.order = scope.getDirection() === 'md-asc' ? '-' + scope.orderBy : scope.orderBy;
        } else {
          headCtrl.order = scope.getDirection() === 'md-asc' ? scope.orderBy : '-' + scope.orderBy;
        }