mat-table how to align mat-header with the mat-cell width - angular-material

I'm new with flex and I have quite made good with my mat-table.
Unfortunately my header is not following my cell width.
Here's a picture of my result.
As you see my header is not align with my cell.
Here's my CSS code, Like I said I'm new, so maybe I missed something.
#import "./../../styles.scss";
.mat-header-row {
width: 100%;
min-height: 20px;
padding: 0px 0px 0px 4px;
}
.mat-row {
width: 100%;
min-height: 12px;
display: inline-flex;
// min-width: 100%;
}
.mat-header-cell {
justify-content: left;
font-size: smaller;
font-weight: bold;
padding: 0px 0px 0px 4px;
}
.mat-cell {
justify-content: left;
border-top: 1px solid crimson;
font-size: smaller;
padding: 0px 0px 0px 4px;
text-align: left;
align-items: flex-start;
}
.mat-cell-points {
flex: 0 0 20px !important;
white-space: unset !important;
}
.mat-cell-concession{
flex: 0 0 200px !important;
white-space: unset !important;
justify-content: left;
border-top: 1px solid crimson;
font-size: smaller;
padding: 0px 0px 0px 4px;
text-align: left;
}
.rcorner1 {
border-radius: 25px;
background: mat-color($accent, 300);
padding: 20px;
}
.example-container {
display: flex;
flex-direction: column;
// min-width: 200px;
max-width: 380px;
}
label {
min-width: 15%;
}
.mat-row:nth-child(1n + 1) {
background-color: mat-color($accent, lighter);
}
.mat-row:not(:nth-child(2n + 1)) {
background-color: mat-color($primary, 300);
}
.example-element-row:hover {
background: mat-color($accent, 800);
}
.example-element-row:active {
background: #efefef;
}
And my HTML code:
<div class="example-container mat-elevation-z8 alternate-theme mat-app-background" color="primary">
<div class="mat-header-cell">
{{ this.getTypeInfo(this.typeList.TypeBourse) }}
</div>
<mat-table [dataSource]="bourseDetail" class="mat-elevation-z8">
<!-- https://stackoverflow.com/questions/53084892/angular-material-table-cell-formatting/53096778 -->
<!-- Position Column -->
<ng-container matColumnDef="Position">
<mat-header-cell *matHeaderCellDef matTooltip="Position"> # </mat-header-cell>
<mat-cell *matCellDef="let element">{{ element.Position }}</mat-cell>
</ng-container>
<!-- Concession Column -->
<ng-container matColumnDef="nom">
<mat-header-cell *matHeaderCellDef>Concession</mat-header-cell>
<mat-cell class="mat-cell-concession" *matCellDef="let element">
<ng-container *ngIf="element.Concession.Nom; else elseBlock">
{{ element.Concession.Nom }}
<ng-template #elseBlock>Content to render when condition is false.</ng-template>
</ng-container>
</mat-cell>
</ng-container>
<!-- Points Column -->
<ng-container matColumnDef="Points">
<mat-header-cell *matHeaderCellDef>points</mat-header-cell>
<mat-cell *matCellDef="let element">{{ element.Points }}</mat-cell>
</ng-container>
<!-- Amount Column -->
<ng-container matColumnDef="Montant">
<mat-header-cell *matHeaderCellDef>Gain</mat-header-cell>
<mat-cell *matCellDef="let element">{{ element.Montant | currency }}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns" class="example-element-row"></mat-row>
</mat-table>
</div>
Thanks for your help

Here's my code that works now:
<div class="example-container mat-elevation-z8 alternate-theme mat-app-background" color="primary"
style="width: 450px;">
<div class="div-title">
{{ this.annee }} - {{ this.getTypeInfo(this.typeList.TypeBourse) }}
</div>
<mat-table [dataSource]="bourseDetail" class="mat-elevation-z8">
<!-- https://stackoverflow.com/questions/53084892/angular-material-table-cell-formatting/53096778 -->
<!-- Position Column -->
<ng-container matColumnDef="Position">
<mat-header-cell class="mat-cell" *matHeaderCellDef matTooltip="Position"> Pos </mat-header-cell>
<mat-cell class="mat-cell-column" *matCellDef="let element">{{ element.Position }}</mat-cell>
</ng-container>
<!-- Concession Column -->
<ng-container matColumnDef="nom">
<mat-header-cell class="mat-cell-concession" *matHeaderCellDef>Concession</mat-header-cell>
<mat-cell class="mat-cell-concession mat-cell-column" *matCellDef="let element">
<ng-container *ngIf="element.Concession.Nom">
{{ element.Concession.Nom }}
</ng-container>
<ng-container *ngIf="!element.Concession.Nom">
Info manquante
</ng-container>
</mat-cell>
</ng-container>
<!-- Points Column -->
<ng-container matColumnDef="Points">
<mat-header-cell class="mat-cell" *matHeaderCellDef>points</mat-header-cell>
<mat-cell class="mat-cell-column" *matCellDef="let element">{{ element.Points }}</mat-cell>
</ng-container>
<!-- Amount Column -->
<ng-container matColumnDef="Montant">
<mat-header-cell class="mat-cell" *matHeaderCellDef>Gain</mat-header-cell>
<mat-cell class="mat-cell-column" *matCellDef="let element">{{ element.Montant | currency }}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns" class="example-element-row"></mat-row>
</mat-table>
And the CSS file:
#import "./../../styles.scss";
.mat-table {
width: 100%;
}
.mat-row {
width: 100%;
min-height: 12px;
}
.div-title {
text-align: center;
font-size: medium;
font-weight: bold;
padding: 4px;
}
.mat-header-cell {
min-height: 12px;
font-size: smaller;
font-weight: bold;
}
.mat-header-row {
width: 100%;
min-height: 10px;
padding: 0px 0px 0px 4px;
}
.mat-cell-column {
border-top: 1px solid crimson;
}
.mat-cell {
flex: 0 0 50px !important;
white-space: unset !important;
justify-content: left;
font-size: smaller;
padding: 0px 0px 0px 4px;
text-align: left;
}
.mat-cell-concession {
flex: 0 0 250px !important;
min-width: 250px !important;
white-space: unset !important;
justify-content: left;
font-size: smaller;
padding: 0px 0px 0px 4px;
text-align: left;
color: black;
}
.mat-row:nth-child(1n + 1) {
background-color: mat-color($accent, lighter);
}
.mat-row:not(:nth-child(2n + 1)) {
background-color: mat-color($primary, 300);
}
.example-element-row:hover {
background: mat-color($accent, 800);
}
.example-element-row:active {
background: #efefef;
}

Related

Angular material table adding an extra row for each record, While implementing the expansion of rows code in angular 9

I am at initial stage in learning angular 9.I have a mat-table which is having an icon for each row,and I am trying to write code such that on click of icon the particular row should be expanded. My following code is working fine but on load of the page, an extra row is being added to each record in
import { Component, OnInit, ViewChild, ChangeDetectorRef, ElementRef } from '#angular/core';
import { animate, state, style, transition, trigger } from '#angular/animations';
import { LoginService } from '../login.service';
import { MatTableDataSource } from '#angular/material/table';
import { Candidate } from '.././Models/candidate.model';
#Component({
selector: 'app-candidates',
templateUrl: './candidates.component.html',
styleUrls: ['./candidates.component.scss'],
animations: [
trigger('detailExpand', [
state('collapsed', style({ height: '0px', minHeight: '0' })),
state('expanded', style({ height: '*' })),
transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')),
]),
],
})
export class CandidatesComponent implements OnInit {
columnsToDisplay: string[] = ['arrow', 'reference', 'name', 'date', 'grade', 'location', 'status', 'action'];
dataSource = new MatTableDataSource();
expandedElement: Candidate | null;
categories = [
{ value: 'category', viewValue: 'category' },
{ value: 'C1', viewValue: 'grade3' },
{ value: 'C2', viewValue: 'grade4' },
{ value: 'C3A', viewValue: 'grade2' },
];
constructor(private loginService: LoginService) { }
ngOnInit(): void {
// this.loginService.getCandidates().subscribe(results => {
// console.log("inisde candidate ts ===>", results);
// if (!results) { return };
// this.dataSource.data = results;
// });
this.dataSource.data=[
{
"referenceId": "ENk2N789",
"firstName": "heidi",
"middleName": null,
"lastName": null,
"grade": "ITA",
"location": "Chennai",
"status": "New",
"emailId": "heidi#gmail.com",
"phone": "97 9884729272",
"empId": "135124",
"reportingAddress": "Chennai Siruseri",
"startDate": "2020-07-06T16:48:33.743+00:00",
"confirmDate": null,
"taggedBuddy": "yes",
"isExpanded" : false
},
{
"referenceId": "QWK2N789",
"firstName": "nemo",
"middleName": null,
"lastName": null,
"grade": "C!",
"location": "Hyderabad",
"status": "New",
"emailId": "nemo#gmail.com",
"phone": "97 9245367234",
"empId": "123456",
"reportingAddress": "Chennai Siruseri",
"startDate": "2020-07-06T16:48:33.743+00:00",
"confirmDate": null,
"taggedBuddy": "yes",
"isExpanded" : false
},
{
"referenceId": "ESR2N789",
"firstName": "minion",
"middleName": null,
"lastName": null,
"grade": "ITA",
"location": "Chennai",
"status": "New",
"emailId": "minion#tcs.com",
"phone": "97 9245677234",
"empId": "1332130",
"reportingAddress": "Chennai Siruseri",
"startDate": "2020-07-06T16:48:33.743+00:00",
"confirmDate": null,
"taggedBuddy": "yes",
"isExpanded" : false
}
]
}
approveCandidate() {
console.log("approve ta gbuddy");
}
tagBuddy() {
console.log("gettign ta gbuddy");
}
}
.table-bg1{
top: 57px;
left: 0px;
width: 1366px;
height: 268px;
background: url('../../assets/images/Diversity-Img.png') rgba(0, 0, 0, 0.36) 0% 0% no-repeat padding-box;
background-size: cover;
background-blend-mode: multiply;
margin-top: 57px;
//opacity: 0.36;
}
a{
text-decoration: none;
}
.cand_heading{
top: 152px;
left: 165px;
width: 230px;
height: 61px;
text-align: center;
font: Bold 50px/61px Calibri;
letter-spacing: 0px;
color: #FFFEFE;
position: absolute;
//opacity: 1;
}
.table-bg2{
top: 325px;
left: 0px;
width: 1366px;
height: 702px;
background: url('../../assets/images/shutterstock_709202158.png') rgba(0, 0, 0, 0.36) 0% 0% no-repeat padding-box;
background-size: cover;
background-blend-mode: multiply;
// opacity: 0.36;
}
.table_layout{
top: 484px;
left: 30px;
width: 1296px;
height: 393px;
background: #FFFFFF 0% 0% no-repeat padding-box;
border-radius: 47px 47px 38px 38px;
opacity: 1;
margin: 21px 40px 89px 30px;
}
.table_header{
top: 484px;
left: 30px;
width: 1296px;
height: 62px;
background: transparent linear-gradient(180deg, #2B74F3 0%, #163A7A 100%) 0% 0% no-repeat padding-box;
border-radius: 38px 38px 0px 0px;
opacity: 1;
}
.column {
float: left;
width: 286px;
padding: 5px;
}
/* Clearfix (clear floats) */
.row::after {
content: "";
clear: both;
display: block;
}
.approve_link {
top: 558px;
left: 1104px;
width: 70px;
height: 20px;
text-align: left;
font: Regular 14px/20px Source Sans Pro;
letter-spacing: 0px;
color: #2D81B7;
opacity: 1;
}
.buddy_tag_link {
top: 559px;
left: 1189px;
width: 101px;
height: 20px;
text-align: left;
font: Regular 14px/20px Source Sans Pro;
letter-spacing: 0px;
color: #2D81B7;
opacity: 1;
}
.catg_dd{
top: 389px;
left: 111px;
width: 315px;
height: 42px;
background: #FFFFFF 0% 0% no-repeat padding-box;
border: 1px solid #707070;
border-radius: 21px;
opacity: 1;
margin: 64px 43px 0px 81px;
}
.ref_id_input {
top: 389px;
left: 469px;
width: 315px;
height: 42px;
background: #FFFFFF 0% 0% no-repeat padding-box;
border: 1px solid #707070;
border-radius: 21px;
opacity: 1;
margin: 64px 43px 0px 0px;
}
.records_dd{
top: 389px;
left: 827px;
width: 173px;
height: 42px;
background: #FFFFFF 0% 0% no-repeat padding-box;
border: 1px solid #707070;
border-radius: 21px;
opacity: 1;
margin: 64px 43px 0px 0px;
}
.search {
top: 389px;
left: 1043px;
width: 173px;
height: 42px;
background: transparent linear-gradient(180deg, #21BF36 0%, #11601B 100%) 0% 0% no-repeat padding-box;
border-radius: 21px;
opacity: 1;
margin: 64px 0px 0px 0px;
}
.export_btn {
top: 962px;
left: 53px;
width: 173px;
height: 42px;
color: white;
background: transparent linear-gradient(180deg, #21BF36 0%, #11601B 100%) 0% 0% no-repeat padding-box;
border-radius: 21px;
margin: 0px 0px 23px 53px;
opacity: 1;
}
mat-icon {
cursor: pointer;
}
.expandIcon{
left: 53px;
width: 20px;
height: 20px;
background:#149AEF 0% 0% no-repeat padding-box;
opacity: 1;
border-radius: 10px;
}
//table css properties
table {
width: 100%;
}
tr.candidate-detail-row {
height: 0;
}
tr.candidate-element-row:not(.candidate-expanded-row):hover {
background: whitesmoke;
}
tr.candidate-element-row:not(.candidate-expanded-row):active {
background: #efefef;
}
.candidate-element-row td {
border-bottom-width: 0;
}
.candidate-element-detail {
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
background-color: #e1e1e1;
box-shadow: inset 2px 3px 8px #c1c1c1;
border-radius: 8px;
}
<app-header></app-header>
<div class="table-bg1">
<span class="cand_heading">Candidates</span>
</div>
<div class="table-bg2">
<div class="row">
<div class="column catg_dd">
<mat-form-field class="">
<mat-select>
<mat-option *ngFor="let category of categories" [value]="category.value">
{{ category.viewValue }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="column ref_id_input">
<mat-form-field class="">
<mat-label>Reference ID</mat-label>
<input matInput placeholder="Reference ID" value="">
</mat-form-field>
</div>
<div class="column records_dd">
<mat-form-field class="">
<mat-select>
<mat-option *ngFor="let category of categories" [value]="category.value">
{{ category.viewValue }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="column search">
<button type="submit">Search</button>
</div>
</div>
<div class="row">
<table mat-table class="table_layout" [dataSource]="dataSource" multiTemplateDataRows>
<!-- Expanded Content Column - The detail row is made up of this one column that spans across all columns -->
<ng-container matColumnDef="arrow">
<th mat-header-cell *matHeaderCellDef mat-sort-header></th>
<td mat-cell *matCellDef="let element">
<mat-icon class="expandIcon" (click)="element.isExpanded = !element.isExpanded">
{{expandedElement === element ? '-' : '+'}}</mat-icon>
</td>
</ng-container>
<ng-container matColumnDef="reference">
<th mat-header-cell *matHeaderCellDef>Reference</th>
<td mat-cell *matCellDef="let element"> {{element.referenceId}}
</td>
</ng-container>
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef>Name</th>
<td mat-cell *matCellDef="let element"> {{element.firstName}}
{{element.middleName}} {{element.lastName}}
</td>
</ng-container>
<ng-container matColumnDef="date">
<th mat-header-cell *matHeaderCellDef>Date</th>
<td mat-cell *matCellDef="let element"> {{element.startDate |date: 'dd/MM/yyyy'}}
</td>
</ng-container>
<ng-container matColumnDef="grade">
<th mat-header-cell *matHeaderCellDef>Grade</th>
<td mat-cell *matCellDef="let element"> {{element.grade}} </td>
</ng-container>
<ng-container matColumnDef="location">
<th mat-header-cell *matHeaderCellDef>Location</th>
<td mat-cell *matCellDef="let element"> {{element.location}} </td>
</ng-container>
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef>Status</th>
<td mat-cell *matCellDef="let element"> {{element.status}} </td>
</ng-container>
<ng-container matColumnDef="action">
<th mat-header-cell *matHeaderCellDef>Action</th>
<td mat-cell *matCellDef="let element">
<a (click)="approveCandidate()" class="approve_link">Approve</a>
<a (click)="tagBuddy()" class="buddy_tag_link">Buddy Tagging</a>
</td>
</ng-container>
<!-- Template for details row -->
<ng-container matColumnDef="expandedDetail">
<td mat-cell *matCellDef="let element" [attr.colspan]="columnsToDisplay.length">
<div class="row candidate-element-detail"
[#detailExpand]="element.isExpanded ? 'expanded' : 'collapsed'">
<div class="row" style="margin-left: 150px;">
<div class="column">
<span> Email ID: {{element.emailId}}</span>
</div>
<div class="column">
<span> Employee ID: {{element.empId}}</span>
</div>
<div class="column">
<span> Start Date:{{element.startDate |date: 'dd/MM/yyyy'}}</span>
</div>
</div>
<div class="row" style="margin-left: 150px;">
<div class="column">
<span> Phone: {{element.phone}}</span>
</div>
<div class="column">
<p>Reporting Address: {{element.reportingAddress}}</p>
</div>
<div class="column">
<span>Confirmation Date:{{element.confirmDate |date: 'dd/MM/yyyy'}}</span>
</div>
</div>
</div>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="columnsToDisplay;sticky: true" class="table_header"></tr>
<tr mat-row *matRowDef="let row; columns: columnsToDisplay;" class="candidate-element-row"
[class.candidate-expanded-row]="element.isExpanded"></tr>
<!-- Extra row to show detail content column -->
<tr mat-row *matRowDef="let row; columns: ['expandedDetail']" class="candidate-detail-row"></tr>
</table>
</div>
<div class="row">
<div class="column">
<button class="export_btn">Export</button>
</div>
</div>
</div>
<app-footer></app-footer>
the table.
Anyone please see my code and help me If I am doing anything wrong or missing something.
table on load of the component
import { Component, OnInit, ViewChild, ChangeDetectorRef,ElementRef } from '#angular/core';
import {animate, state, style, transition, trigger} from '#angular/animations';
import { LoginService } from '../login.service';
import { MatPaginator } from '#angular/material/paginator';
import { MatSort } from '#angular/material/sort';
import { MatTableDataSource } from '#angular/material/table';
import { Candidate } from '.././Models/candidate.model';
#Component({
selector: 'app-candidates',
templateUrl: './candidates.component.html',
styleUrls: ['./candidates.component.scss'],
animations: [
trigger('detailExpand', [
state('collapsed, void', style({ height: '0px',visibility: 'hidden' })),
state('expanded', style({ height: '*'})),
transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')),
transition('expanded <=> void', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)'))
]),
],
})
export class CandidatesComponent implements OnInit {
columnsToDisplay: string[] = ['arrow','reference', 'name', 'date', 'grade', 'location', 'status', 'action'];
dataSource = new MatTableDataSource<Candidate>();
expandedElement: Candidate | null;
constructor(private loginService: LoginService, private cdr: ChangeDetectorRef,private eleRef: ElementRef) { }
ngOnInit(): void {
this.loginService.getCandidates().subscribe(results => {
console.log("inisde candidate ts ===>", results);
if (!results) { return };
this.dataSource.data = results;
});
console.log("this after table displayed expanele on init",this.expandedElement);
}
}
.table-bg1{
top: 57px;
left: 0px;
width: 1366px;
height: 268px;
background: url('../../assets/images/Diversity-Img.png') #000000 0% 0% no-repeat padding-box;
//opacity: 0.36;
}
.cand_heading{
top: 152px;
left: 165px;
width: 230px;
height: 61px;
text-align: center;
font: Bold 50px/61px Calibri;
letter-spacing: 0px;
color: #FFFEFE;
//opacity: 1;
}
.table-bg2{
top: 325px;
left: 0px;
width: 1366px;
height: 702px;
background: url('../../assets/images/shutterstock_709202158.png') #000000 0% 0% no-repeat padding-box;
// opacity: 0.36;
}
.table_layout{
top: 484px;
left: 30px;
width: 1296px;
height: 393px;
background: #FFFFFF 0% 0% no-repeat padding-box;
border-radius: 47px 47px 38px 38px;
opacity: 1;
margin: 21px 40px 89px 30px;
}
.table_header{
top: 484px;
left: 30px;
width: 1296px;
height: 62px;
background: transparent linear-gradient(180deg, #2B74F3 0%, #163A7A 100%) 0% 0% no-repeat padding-box;
border-radius: 38px 38px 0px 0px;
opacity: 1;
}
.column {
float: left;
width: 286px;
padding: 5px;
}
/* Clearfix (clear floats) */
.row::after {
content: "";
clear: both;
display: block;
}
thead{
border-radius: 47px 47px;
}
.approve_link{
top: 558px;
left: 1104px;
width: 70px;
height: 20px;
text-align: left;
font: Regular 14px/20px Source Sans Pro;
letter-spacing: 0px;
color: #2D81B7;
opacity: 1;
}
.buddy_tag_link{
top: 559px;
left: 1189px;
width: 101px;
height: 20px;
text-align: left;
font: Regular 14px/20px Source Sans Pro;
letter-spacing: 0px;
color: #2D81B7;
opacity: 1;
}
.catg_dd{
top: 389px;
left: 111px;
width: 315px;
height: 42px;
background: #FFFFFF 0% 0% no-repeat padding-box;
border: 1px solid #707070;
border-radius: 21px;
opacity: 1;
margin: 64px 43px 0px 81px;
}
.ref_id_input{
top: 389px;
left: 469px;
width: 315px;
height: 42px;
background: #FFFFFF 0% 0% no-repeat padding-box;
border: 1px solid #707070;
border-radius: 21px;
opacity: 1;
margin: 64px 43px 0px 0px;
}
.records_dd{
top: 389px;
left: 827px;
width: 173px;
height: 42px;
background: #FFFFFF 0% 0% no-repeat padding-box;
border: 1px solid #707070;
border-radius: 21px;
opacity: 1;
margin: 64px 43px 0px 0px;
}
.search{
top: 389px;
left: 1043px;
width: 173px;
height: 42px;
background: transparent linear-gradient(180deg, #21BF36 0%, #11601B 100%) 0% 0% no-repeat padding-box;
border-radius: 21px;
opacity: 1;
margin: 64px 0px 0px 0px;
}
::ng-deep .mat-select-content{
width:2000px;
background-color: red;
font-size: 10px;
}
.export_btn{
top: 962px;
left: 53px;
width: 173px;
height: 42px;
color: white;
background: transparent linear-gradient(180deg, #21BF36 0%, #11601B 100%) 0% 0% no-repeat padding-box;
border-radius: 21px;
margin: 0px 0px 23px 53px;
opacity: 1;
}
.ic_add_circle{
top: 680px;
left: 53px;
width: 20px;
height: 20px;
background: #FFFFFF 0% 0% no-repeat padding-box;
opacity: 1;
}
//expansion properties
// .example-detail-row {
// height: 0;
// }
// .example-element-detail {
// overflow: hidden;
// display: flex;
// }
// .example-element-description {
// padding: 16px;
// }
.element-row {
position: relative;
}
.element-row:not(.expanded):hover {
background: #f5f5f5;
}
.element-row.expanded {
border-bottom-color: transparent;
}
i:hover {
cursor: pointer;
}
//tttttttttttttttttttttttttttttttttttttttttttttttttttttt
mat-row.example-detail-row {
height: 0;
}
// mat-row.example-element-row:not(.example-expanded-row):hover {
// background: rgb(46, 235, 8);
// }
mat-row.example-element-row:not(.example-expanded-row):active {
background: grey;
}
.example-element-row mat-cell {
border-bottom-width: 0;
}
// .example-element-detail {
// overflow: hidden;
// display: flex;
// }
mat-icon {
cursor: pointer;
}
.expandIcon{
left: 53px;
width: 20px;
height: 20px;
background:#149AEF 0% 0% no-repeat padding-box;
opacity: 1;
border-radius: 10px;
}
<app-header></app-header>
<div class="table-bg1">
<span class="cand_heading">Candidates</span>
</div>
<div class="table-bg2">
<div class="row">
<mat-table class="table_layout" [dataSource]="dataSource" multiTemplateDataRows>
<!-- Expanded Content Column - The detail row is made up of this one column that spans across all columns -->
<ng-container matColumnDef="arrow">
<mat-header-cell *matHeaderCellDef mat-sort-header></mat-header-cell>
<mat-cell *matCellDef="let element">
<mat-icon class="expandIcon"
(click)="expandedElement = expandedElement === element ? null : element">
{{expandedElement === element ? '-' : '+'}}</mat-icon>
</mat-cell>
</ng-container>
<ng-container matColumnDef="reference">
<mat-header-cell *matHeaderCellDef>Reference</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.referenceId}}
</mat-cell>
</ng-container>
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.firstName}}
{{element.middleName}} {{element.lastName}}
</mat-cell>
</ng-container>
<ng-container matColumnDef="date">
<mat-header-cell *matHeaderCellDef>Date</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.startDate |date: 'dd/MM/yyyy'}}
</mat-cell>
</ng-container>
<ng-container matColumnDef="grade">
<mat-header-cell *matHeaderCellDef>Grade</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.grade}} </mat-cell>
</ng-container>
<ng-container matColumnDef="location">
<mat-header-cell *matHeaderCellDef>Location</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.location}} </mat-cell>
</ng-container>
<ng-container matColumnDef="status">
<mat-header-cell *matHeaderCellDef>Status</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.status}} </mat-cell>
</ng-container>
<ng-container matColumnDef="action">
<mat-header-cell *matHeaderCellDef>Action</mat-header-cell>
<mat-cell *matCellDef="let element">
Approve
Buddy Tagging
</mat-cell>
</ng-container>
<ng-container matColumnDef="expandedDetail">
<mat-cell *matCellDef="let element" [attr.colspan]="columnsToDisplay.length">
<div class="example-element-detail"
[#detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'"
[style.height]="element == expandedElement ? 'unset' : '0 !important'">
<div class="row" style="margin-left: 150px;">
<div class="column">
<span> Email ID: {{element.emailId}}</span>
</div>
<div class="column">
<span> Employee ID: {{element.empId}}</span>
</div>
<div class="column">
<span> Start Date:{{element.startDate |date: 'dd/MM/yyyy'}}</span>
</div>
</div>
<div class="row" style="margin-left: 150px;">
<div class="column">
<span> Phone: {{element.phone}}</span>
</div>
<div class="column">
<p>Reporting Address: {{element.reportingAddress}}</p>
</div>
<div class="column">
<span>Confirmation Date:{{element.confirmDate |date: 'dd/MM/yyyy'}}</span>
</div>
</div>
</div>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="columnsToDisplay" class="table_header"></mat-header-row>
<mat-row *matRowDef="let row; columns: columnsToDisplay;" class="example-element-row"
[class.example-expanded-row]="expandedElement === element">
</mat-row>
<mat-row *matRowDef="let row; columns: ['expandedDetail']" class="example-detail-row"></mat-row>
</mat-table>
</div>
<div class="row">
<div class="column">
<button class="export_btn">Export</button>
</div>
</div>
</div>
<app-footer></app-footer>
enter code here
I was not able to run your code successfully by copy it, if you can put in stackblitz i can check again, meanwhile you can have a look to the similar functionality example here
From above code, the approach to create material table is with display:flex style, and not native HTML table.
With reference to
https://material.angular.io/components/table/overview#tables-with-display-flex
But the above documentation also suggest :
Note that this approach means you cannot include certain native-table features such colspan/rowspan or have columns that resize themselves based on their content.
You might also facing issue because few features are not working properly in this alternate approach.
So try to make the table native HTML type.
Here is an example : example

Text Overlapping on Email Signature from iPhone to Gmail.com

When I send my email signature from an iPhone and view it at gmail.com the text starts overlapping. I have checked all settings on the phone and all text size etc is defaulted. I don't have any line-height anywhere and after I paste I am shaking the phone to 'undo' to stop picking up the default character attributes. By removing sections of text I managed to isolate that the top table is causing the problem - if I remove that it works, but then my text doesn't sit side-by-side with the image.
Anyone see anything else i've missed? Have spent hours and feel like i'm hitting a brick wall.
<body>
<table cellpadding="0" cellspacing="0" border="0" height="200" width="550" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;"><tr><td style="border-right: solid 1px #c1c1c1; padding-right: 0px; display: block; clear: both;"><img src="https://url.com/portfolio.jpg" width="133px" height="200px"></td>
<td style="padding-top: 0; padding-bottom: 0; padding-left: 15px; padding-right: 0;">
<table cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;"><tr><td colspan="2" style="padding-bottom: 0px; color: #221f1f; font-size: 16px; font-family: Arial, Helvetica, sans-serif; font-weight:bold;"><img src="https://www.url.com/emailsig/logo.png" width="250px"></td></tr>
<tr><td colspan="2" style="padding-bottom: 10px; padding-top: 5px; color: #221f1f; font-size: 21px; font-family: Arial, Helvetica, sans-serif; font-weight:bold;">Name Here</td></tr>
<tr><td colspan="2" style="padding-bottom: 2px; color: #70bcc9; font-size: 16px; font-family: Arial, Helvetica, sans-serif; font-weight: bold;">Title</td></tr>
<tr><td colspan="2" valign="top" style="vertical-align: top; color: #545454; font-size: 13px; font-family: Arial, Helvetica, sans-serif; padding-top:0px; padding-bottom: 3px;"><span style="color: #9eb333; font-weight:bold;">► </span>mywebsite.com</tr>
<tr><td colspan="2" valign="top" style="vertical-align: top; color: #545454; font-size: 13px; font-family: Arial, Helvetica, sans-serif; padding-top:0px; padding-bottom: 5px;"><span style="color: #9eb333; font-weight:bold;">►</span> 555-555-5555 <span style="color: #9eb333; font-weight:bold;">►</span> 555-555-5555</tr>
<tr><td colspan="2" valign="top" style="vertical-align: top; color: #545454; font-size: 13px; font-family: Arial, Helvetica, sans-serif; padding-bottom: 7px;">Location</td></tr>
<tr><td valign="top" style="vertical-align: top; color: #9eb333; font-size: 12px; font-family: Arial, Helvetica, sans-serif;"><img src="https://www.myurl.com/emailsig/tw-facebook.png" width="18px" height="18px">
<img src="https://www.myurl.com/emailsig/tw-instagram.png" width="18px" height="18px">
<img src="https://www.myurl.com/emailsig/tw-youtube.png" width="18px" height="18px">
<img src="https://www.myurl.com/emailsig/tw-linkedin.png" width="18px" height="18px"><span style="display: inline-block;"> » JOIN OUR MAILING LIST</span></td></td></tr>
</table>
</td></tr></table>
<p style="color: #545454; font-size: 10px; font-family: Arial, Helvetica, sans-serif; padding-top:0px;">Confidentiality text to go here.</p>
</body>
Edited to include screenshot of how it looks (the confidentiality text is overlapping)
Can you try this one? I have just corrected a few errors
<body>
<table cellpadding="0" cellspacing="0" border="0" height="200" width="550" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;">
<tr>
<td style="border-right: solid 1px #c1c1c1; padding-right: 0px; display: block; clear: both;"><a href="https://www.url.com"><img src="https://url.com/portfolio.jpg" width="133px"
height="200px"></a></td>
<td style="padding-top: 0; padding-bottom: 0; padding-left: 15px; padding-right: 0;">
<table cellpadding="0" cellspacing="0" border="0" style="background: none; border-width: 0px; border: 0px; margin: 0; padding: 0;">
<tr>
<td style="padding-bottom: 0px; color: #221f1f; font-size: 16px; font-family: Arial, Helvetica, sans-serif; font-weight:bold;">
<img src="https://www.url.com/emailsig/logo.png" width="250px"></td>
</tr>
<tr>
<td style="padding-bottom: 10px; padding-top: 5px; color: #221f1f; font-size: 21px; font-family: Arial, Helvetica, sans-serif; font-weight:bold;">
Name Here</td>
</tr>
<tr>
<td style="padding-bottom: 2px; color: #70bcc9; font-size: 16px; font-family: Arial, Helvetica, sans-serif; font-weight: bold;">
Title</td>
</tr>
<tr>
<td valign="top" style="vertical-align: top; color: #545454; font-size: 13px; font-family: Arial, Helvetica, sans-serif; padding-top:0px; padding-bottom: 3px;">
<span style="color: #9eb333; font-weight:bold;">► </span>mywebsite.com
</td>
</tr>
<tr>
<td valign="top" style="vertical-align: top; color: #545454; font-size: 13px; font-family: Arial, Helvetica, sans-serif; padding-top:0px; padding-bottom: 5px;">
<span style="color: #9eb333; font-weight:bold;">►</span> 555-555-5555
<span style="color: #9eb333; font-weight:bold;">►</span> 555-555-5555
</td>
</tr>
<tr>
<td valign="top" style="vertical-align: top; color: #545454; font-size: 13px; font-family: Arial, Helvetica, sans-serif; padding-bottom: 7px;">
Location</td>
</tr>
<tr>
<td valign="top" style="vertical-align: top; color: #9eb333; font-size: 12px; font-family: Arial, Helvetica, sans-serif;">
<a href="https://www.facebook.com/"><img
src="https://www.myurl.com/emailsig/tw-facebook.png" width="18px" height="18px"></a>
<a href="https://www.instagram.com/"><img
src="https://www.myurl.com/emailsig/tw-instagram.png" width="18px"
height="18px"></a>
<a href="https://www.youtube.com/"><img src="https://www.myurl.com/emailsig/tw-youtube.png"
width="18px" height="18px"></a>
<img src="https://www.myurl.com/emailsig/tw-linkedin.png" width="18px" height="18px">
<br> <br>
<span style="display: inline-block;"> » JOIN OUR
MAILING LIST</span>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p style="color: #545454; font-size: 10px; font-family: Arial, Helvetica, sans-serif; padding-top:0px;">
Confidentiality text to go here.</p>
</body>
As well as the fixes Rasmus has made to the code, this seems to be an issue on send/forward.
What happens if you place the confidentiality text in it's own 100% table?

Busy indicator for Asp.net MVC

It is possible to implement busy indicator to indicate the processing of the controller for form postback call without using AJAX?
Try this using html. Add this in common view. Using java-script call the ID where ever you want like this $("#loading").show() to show and $("#loading").hide() to hide
<div id="loading" style="display: none;">
<table style="height: 100%; border: 0; width: 100%; position: fixed; top: 0; left: 0; background-color: #FAFAFA; opacity: 0.8; filter: alpha(opacity=80); z-index: 9000;">
<tbody>
<tr>
<td style="width: 100%; text-align:center; vertical-align : middle;"> <div id="Loadingtext" style="font-family: Arial; font-size: 24px; opacity: 1; filter: alpha(opacity=100); font-weight: bold; color: #000000; text-align: center; padding-top: 5px;">Please wait</div>
</td>
</tr>
</tbody>
</table>
</div>

MSO Conditionals and ERB Tags

I'm trying to embedded ruby content in a MSO conditional in a mailer.html.erb in a rails server.
Because dosen't seem to work since href renders "www.example.com/edit/<%= #user[:id] %>/<%= #user[:reset_digest] %>" for mso.
<!--[if mso]>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="border-spacing: 0; border-collapse: collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;">
<tr>
<td style="padding-right: 10px; padding-left: 10px; padding-top:10px; padding-bottom:10px;" align="center">
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="https://www.example.com/doctores/edit/<%= #user[:id] %>/<%= #user[:reset_digest] %>" style="height:42px; v-text-anchor:middle; width:170px;" arcsize="15%" strokecolor="#3AAEE0" fillcolor="#3AAEE0">
<w:anchorlock/>
<center style="color:#ffffff; font-family:'Helvetica Neue', Helvetica, Arial, sans-serif; font-size:16px;">
<![endif]-->
<a href="https://www.example.com/doctores/edit/<%= #user[:id] %>/<%= #user[:reset_digest] %>" target="_blank" style="display: inline-block;text-decoration: none;-webkit-text-size-adjust: none;text-align: center;color: #ffffff; background-color: #3AAEE0; border-radius: 6px; -webkit-border-radius: 6px; -moz-border-radius: 6px; max-width: 150px; width: 110px; width: auto; border-top: 0px solid transparent; border-right: 0px solid transparent; border-bottom: 0px solid transparent; border-left: 0px solid transparent; padding-top: 5px; padding-right: 20px; padding-bottom: 5px; padding-left: 20px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;mso-border-alt: none">
<span style="font-size:12px;line-height:24px;"><span style="font-size: 16px; line-height: 32px;" data-mce-style="font-size: 16px;">Corregir Datos</span></span>
</a>
Thanks
The only solution I have found is to string concat your ruby vars into the if block and output the whole mso conditional, something like so in your case:
<%== '<!--[if mso]>
<table width="100%" ...>
<tr>
<td style="...">
<v:roundrect ... href="https://www.example.com/doctores/edit/' + #user[:id] + '/' + #user[:reset_digest] + '" style="..." ...>
<w:anchorlock/>
<center style="...">
<![endif]-->' %>
Notice the use of the <%== 'raw' erb tag, I had inconsistent results with the regular escaped <%= tag.
Is frankly an ugly, hacky solution but then its not like using mso tags for emails is pretty ;)

jQuery Mobile forms combining input elements

When using jQuery mobile, is it possible to combine a checkbox or button with a text input? Something like in my image below.
I want to use it as field validation so it will turn red or green when user updates the field.
jQuery Mobile does not include this, but you can do it via CSS.
Here is a DEMO with a couple of options
The first uses a table, so the left button is always the same size and the input grows/shrinks on window resize. While the second option uses a div and bothe button and label grow shrink.
Fot the table, the css removes borders and spacing on the table and sets the first td width to a constant value. The rest of the css makes the button and input look right:
<table id="specialContTbl">
<tr>
<td class="btntd">
<button data-role="none" id="btn">B</button>
</td>
<td class="inptd">
<input data-role="none" type="text" id="inp1" name="inp1" value="" placeholder="enter some text" />
</td>
</tr>
</table>
#specialContTbl {
border-spacing: 0;
border-collapse: collapsed;
}
#specialContTbl td {
padding:0;
margin: 0;
border: 0;
vertical-align: top;
}
#specialContTbl td:first-child{
width: 60px;
}
#specialContTbl{
width: 100%;
}
#specialContTbl button, #specialContTbl input {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#specialContTbl button {
font-weight: normal;
background: #00f050;
padding: 5px;
color: #333;
border: 1px solid #d4d4d4;
border-right: 0;
border-bottom-left-radius:1em;
border-top-left-radius: 1em;
line-height: 28px;
height: 38px;
width: 100%;
float: left;
text-align: center;
cursor: pointer;
white-space:nowrap;
}
#specialContTbl input {
width: 100%;
height: 38px;
padding: 8px;
border: 1px solid #d4d4d4;
border-bottom-right-radius: 1em;
border-top-right-radius: 1em;
line-height: 18px;
float: right;
box-shadow: inset 0px 2px 2px #ececec;
}
#specialContTbl input:focus {
outline: 0;
}

Resources