Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material table should be responsive #10732

Closed
pierre03 opened this issue Apr 6, 2018 · 6 comments
Closed

Material table should be responsive #10732

pierre03 opened this issue Apr 6, 2018 · 6 comments

Comments

@pierre03
Copy link

pierre03 commented Apr 6, 2018

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?

@benneq
Copy link

benneq commented Apr 6, 2018

This is no issue / bug.

Just Build your own table component which internally uses mat-table and sets the displayedColumns according to the Display size.

@josephperrott
Copy link
Member

Please keep GitHub issues for bug reports / feature requests. Better avenues for troubleshooting / questions are stack overflow, gitter, mailing list, etc.

@andrewseguin
Copy link
Contributor

andrewseguin commented 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. #8494 (comment)

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

@kakins
Copy link

kakins commented Aug 27, 2018

@andrewseguin Thanks for that example. I feel it almost gets me there, but I'm not quite sure what to do if your label text is long... i'd the "column" for the labels to align, or at least not wrap the text. Any ideas?

image

@av1m
Copy link

av1m commented 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>

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants