【发布时间】:2020-01-12 04:43:45
【问题描述】:
我们正在尝试实现如下图所示的表格设计 POC,它具有以下特性。
问题在于以下功能
1) Expand and collapse behavior should be per row(Not for all rows at a time).2) It should have value of particular row on click of any action from action-toolbar(i.e. Config, History, etc in image).
HTML
<ng-container matColumnDef="symbol">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Symbol </th>
<td mat-cell *matCellDef="let element">
<div [ngClass]="showFloatingButtons == true ? 'floating-pane-active' : 'floating-pane-deactive'"
class="button-row">
<mat-icon mat-fab *ngIf="showFloatingButtons == true" color="primary" class="floating-buttons">offline_pin
</mat-icon>
<mat-icon mat-fab *ngIf="showFloatingButtons == true" color="primary" class="floating-buttons">query_builder
</mat-icon>
<mat-icon mat-fab *ngIf="showFloatingButtons == true" color="primary" class="floating-buttons" disabled>restore
</mat-icon>
<mat-icon mat-fab *ngIf="showFloatingButtons == true" color="primary" class="floating-buttons">
play_circle_filled</mat-icon>
<mat-icon (click)="toggleFloat()" class="sky_blue">more_horiz</mat-icon>
</div>
</td>
CSS
table {
width: 100%;
}
.mat-form-field {
font-size: 14px;
width: 50%;
}
.mat-column-position {
max-width: 100px;
min-width: 10px;
}
.mat-column-name {
max-width: 100px;
min-width: 10px;
}
.example-trigger {
display: inline-block;
}
.floating-buttons {
z-index: 2;
// position: fixed;
overflow: auto;
top: auto;
left: auto;
}
.floating-pane-active {
background-color: rgba(215, 228, 230, 0.39);
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
background-position: right;
background-repeat: repeat;
}
.floating-pane-deactive {
background-color: rgba(215, 228, 230, 0.39);
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
background-position: right;
background-repeat: repeat;
width: 30px;
}
.button-row {
align-items: center;
justify-content: space-around;
}
.action-buttons {
width: 20px;
}
.sky_blue {
color: skyblue;
}
.mat-column-symbol {
word-wrap: break-word !important;
white-space: unset !important;
flex: 0 0 10% !important;
width: 10% !important;
overflow-wrap: break-word;
word-wrap: break-word;
word-break: break-word;
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
text-align: right;
}
TS(只放重要的行)
showFloatingButtons = false;
仅供参考:我已将 link 用于可扩展行表。
请查找演示代码here on stackblitz 了解更多信息。
PS:这里的主要问题是实现一次扩展单行图标。
【问题讨论】:
-
stackblitz 样本会有很大帮助。
-
好的here是的。
标签: html css angular angular-material angular-material2