question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Material table should be responsive

See original GitHub issue

Bug, feature request, or proposal:

Can not set the table to be responsive.

What is the expected behavior?

I have a default columns list by using *matHeaderRowDef parameter. like: <mat-header-row *matHeaderRowDef="defaultColumns"></mat-header-row>

I need to set another columns list to display for smartphone. This expected columns list should be different to the default columns list and trigged automatically on smartphone.

What is the current behavior?

I didn’t find any example, can you help me please?

What are the steps to reproduce?

Providing a StackBlitz reproduction is the best way to share your issue.
StackBlitz starter: https://goo.gl/wwnhMV

What is the use-case or motivation for changing an existing behavior?

I need something like this for Angular 5 for the company use: https://codepen.io/zavoloklom/pen/IGkDz

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 5 Material latest version

Is there anything else we should know?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
andrewseguincommented, Apr 6, 2018

Duplicate of #8494

@pierre03 Here’s a comment I made on that issue that may help guide you into creating a responsive table. https://github.com/angular/material2/issues/8494#issuecomment-359607760

In that example, I used the same columns. However, if you want to change the columns based on the screen size, try using the CDK’s breakpoint observer.

Here’s a quick example showing this: https://stackblitz.com/edit/angular-mohmt5-y88uhq?file=app%2Ftable-basic-example.ts

4reactions
av1mcommented, Jul 2, 2019

An alternative is to use responsive bootstrap tables, see here

For example :

<div class='table-responsive mat-elevation-z8'>
    <mat-table [dataSource]="data">
       // code ...
    </mat-table>
</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Material Table is not responsive · Issue #1395 - GitHub
Material Table is not responsive. It only reduces the width of the table when shrinking a page. A lot of other table libraries...
Read more >
How to make an Angular Material table responsive
I created a little directive which can be applied to a mat-table table to make it responsive. This way it is easy to...
Read more >
Angular Material Table Responsive - StackBlitz
Starter project for Angular apps that exports to the Angular CLI.
Read more >
Responsive table using Angular Material
In this article, we discuss how to easily implement a responsive table with pagination using Angular Material. Here we have use mat-table, ...
Read more >
Table | Angular Material
The mat-table provides a Material Design styled data-table that can be used to display rows of data. This table builds on the foundation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found