-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentfeatureThis issue represents a new feature or feature request rather than a bug or bug fixThis issue represents a new feature or feature request rather than a bug or bug fix
Description
Bug, feature request, or proposal:
Feature request
What is the expected behavior?
I need to be able to disable sorting under some circumstances on column level. I'd like to do something like [mat-sort-header]="enabled"
where enabled is boolean.
What is the current behavior?
I'm not able to dynamically disable sorting
I also experimented with
@ViewChild(MatSort) sort: MatSort
//and later
this.sort.sortables.forEach((value, key) => {
this.sort.deregister(value)
})
but for some reason this does not do anything when template is set like this:
<mat-table matSort [dataSource]="dataSource" [matSortDisableClear]="true">
<ng-container matColumnDef="id">
<mat-header-cell *matHeaderCellDef mat-sort-header> ID </mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.id}} </mat-cell>
</ng-container>
.
.
.
The only way to pull this off is to have duplicate columns, one where mat-sort-header
is declared and one where it is not. (And toggle the matHeaderRowDef
and columns
accordingly.)
mrbatista, iget-master, StabakSen, j2L4e, tamim73 and 1 more
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentfeatureThis issue represents a new feature or feature request rather than a bug or bug fixThis issue represents a new feature or feature request rather than a bug or bug fix