Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide Angular material 2 table, specific header and its column

I just tried to hide an Angular material 2 table statusid header and column like following.

        <mat-table class="mat-elevation-z1" #table [dataSource]="dataSourceHE">
            <ng-container hidden="hidden" cdkColumnDef="statusid">
                <mat-header-cell hidden="hidden"> Id </mat-header-cell>
                <mat-cell hidden="hidden"> {{row.statusid}} </mat-cell>
            </ng-container>
         </mat-table>

but this is not working properly. if this possible, how can I do this ?

like image 258
Kelum Avatar asked Dec 12 '25 06:12

Kelum


1 Answers

You simply need to change Column Map in component. Adding or removing any key inside it causes the table to show or hide the corresponding column.

Don't try to use CSS or HTML solutions like using hidden attribute or display: none; CSS rule, they turn the code into a dirty and fallible one.

like image 179
Amirhossein Mehrvarzi Avatar answered Dec 15 '25 09:12

Amirhossein Mehrvarzi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!