简体   繁体   English

隐藏/显示 Angular 材料垫对话框中的列

[英]Hide/Show column in Angular material mat-dialog

I am showing mat-dialog as show in the code我在代码中显示 mat-dialog

I gave height and width static(Not sure if I can change after showing Mat-dialog)我给了高度和宽度静态(不确定在显示 Mat-dialog 后是否可以更改)

 const dialogConfig = new MatDialogConfig();
dialogConfig.disableClose = true;
dialogConfig.autoFocus = false;
dialogConfig.height = '700px';
dialogConfig.width = '700px';    
this.dialog.open(etailsComponent, dialogConfig);

So, In Mat-dialog, I want to show data in two columns.所以,在 Mat-dialog 中,我想在两列中显示数据。 One of the two columns is of width 150px and user wants to show or hide this column on button click(which is working right now).两列中的一列宽度为 150 像素,用户希望在单击按钮时显示或隐藏此列(目前正在运行)。

When I hide the column, the other column will expand to cover the space of 150px.当我隐藏该列时,另一列将扩展以覆盖 150px 的空间。

1) I don't want the column to be expand on hide 1)我不希望该列在隐藏时展开

2) After column hide, I dont want to show the empty space.(I think this is tricky) 2)列隐藏后,我不想显示空白空间。(我认为这很棘手)

I am using Flex container to expand the column.我正在使用 Flex 容器来扩展列。

What would be the best design?最好的设计是什么?

You need to use css property visibility to hidden state.您需要使用 css 属性可见性来隐藏 state。 Rather than *ngIf or Css display: none, Both property removes elements from Dom and space of those would be free on html.而不是 *ngIf 或 Css 显示:无,这两个属性都从 Dom 中删除元素,并且这些元素的空间将在 html 上释放。 So use visibility.所以使用可见性。 This is just hide elements, but Dom is not changable.这只是隐藏元素,但 Dom 是不可更改的。

visibility: visible to visibility: hidden; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM