[英]How to make only table content scrollable in a dialog? - Angular Material
I have an Angular Material Dialog which contains Material Table .我有一个包含材料表的Angular 材料对话框。 I would like to make the table content scrollable (not even the table header).我想让表格内容可滚动(甚至不包括表格标题)。 By default, the dialog's content is scrollable which is not what I want.默认情况下,对话框的内容是可滚动的,这不是我想要的。 Please see the example here请在此处查看示例
It can be easily achieved by using flex:使用 flex 可以轻松实现:
Add dialog.component.scss
file to styleUrls of your component with the following rules:使用以下规则将dialog.component.scss
文件添加到组件的 styleUrls 中:
:host,
form {
display: flex;
flex-direction: column;
height: 100%;
}
form,
.table-body {
flex: auto;
overflow-y: auto;
}
Add sticky: true to your table header:添加sticky: true到你的表header:
*matHeaderRowDef="displayedColumns; sticky: true"
Here is the working example:这是工作示例:
https://stackblitz.com/edit/angular-material-table-with-form-xuayxj https://stackblitz.com/edit/angular-material-table-with-form-xuayxj
Just add this style on your table max-height: 200px;overflow:auto;
只需在您的表格上添加此样式max-height: 200px;overflow:auto;
& create mat header row sticky like this: &创建垫子 header 像这样粘贴:
<mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></mat-header-row>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.