4

is there any way how to set different width for column ?

After many tries, it seems columns are even, ignoring all styles.

Edric
  • 24,639
  • 13
  • 81
  • 91
Pavel Franta
  • 1,273
  • 2
  • 11
  • 24
  • Does this answer your question? [md-table - How to update the column width](https://stackoverflow.com/questions/45159066/md-table-how-to-update-the-column-width) – ywbaek Apr 07 '20 at 17:54

2 Answers2

8

yes, it is possible using css .mat-column-<matColumnDef-value>, suppose you have a column def "group" like:

<!-- Group Column -->
<ng-container matColumnDef="group">
  <mat-header-cell *matHeaderCellDef mat-sort-header>Group</mat-header-cell>
  <mat-cell *matCellDef="let element">
    {{element.group}}
  </mat-cell>
</ng-container>

In the css you can set the width:

.mat-column-group {
  width: 150px;
  max-width: 150px;
}
  • 1
    is there any way to define same size for the column even screen size changes? https://stackoverflow.com/questions/65296518/how-to-support-same-column-size-when-screen-size-reducing-in-angular-material-ta – app Dec 14 '20 at 23:12
0

this is awkward, it is not possible to override styles by width... min-width has to be applied.

Pavel Franta
  • 1,273
  • 2
  • 11
  • 24