Skip to content

Simplify tables. Simplify other stuff as well. #13808

@Hermholtz

Description

@Hermholtz

I'm submitting a...


[x] Bug report  
[x] Performance issue
[x] Feature request
[x] Documentation issue or request
[x] Other... Please describe: general direction

Current behavior

This is current example table from the docs. It contains mostly noise and only a little of useful code hidden in garbage.

<mat-table [dataSource]="dataSource">
  <!-- User name Definition -->
  <ng-container cdkColumnDef="username">
    <mat-header-cell *cdkHeaderCellDef> User name </mat-header-cell>
    <mat-cell *cdkCellDef="let row"> {{row.username}} </mat-cell>
  </ng-container>

  <!-- Age Definition -->
  <ng-container cdkColumnDef="age">
    <mat-header-cell *cdkHeaderCellDef> Age </mat-header-cell>
    <mat-cell *cdkCellDef="let row"> {{row.age}} </mat-cell>
  </ng-container>

  <!-- Title Definition -->
  <ng-container cdkColumnDef="title">
    <mat-header-cell *cdkHeaderCellDef> Title </mat-header-cell>
    <mat-cell *cdkCellDef="let row"> {{row.title}} </mat-cell>
  </ng-container>

  <!-- Header and Row Declarations -->
  <mat-header-row *cdkHeaderRowDef="['username', 'age', 'title']"></mat-header-row>
  <mat-row *cdkRowDef="let row; columns: ['username', 'age', 'title']"></mat-row>
</mat-table>

Expected behavior

I would like you to eliminate noise and allow it to look like this instead:

<mat-table [dataSource]="dataSource" [dataItem]="row">
  <!-- User name Definition -->
  <mat-header-cell> User name </mat-header-cell>
  <mat-cell> {{row.username}} </mat-cell>

  <!-- Age Definition -->
  <mat-header-cell> Age </mat-header-cell>
  <mat-cell> {{row.age}} </mat-cell>

  <!-- Title Definition -->
  <mat-header-cell> Title </mat-header-cell>
  <mat-cell> {{row.title}} </mat-cell>
</mat-table>

So much stuff in Angular and Material is done in far too verbose way, it's a huge problem to do things easy way. The choice of defaults is poor and it generates a lot of noise and boilerplate in code. I loathe many stupid features like the need to specify let row in every column, or cdkHeaderCellDef within mat-header-cell. Can't material-header-cell already use this cdkHeaderCellDef by default? Isn't mat-table material enough? Does it need another thing which is called CDK and a lot of cdk... attributes everywhere?

Not to mention that mat-header-row is at the bottom... (in official docs, so I assume this is encouraged even if not required).

I marked "performance issue" as it's impacting performance of developers and in this sense it's relevant.

Feature request would be to eliminate necessity to specify stuff that should be just enabled/included/inferred by default - and allow to customize it for advanced usage scenarios.

Environment


Angular version: 7.0.0

Started my adventure with Angular with v6. Coming from different technologies, all of them much easier to use and not requiring so much verbosity - but allowing a lot of flexibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions