Created
October 22, 2020 23:48
-
-
Save Sutil/fda7b3af25cbe52efc4fa873dc5be3ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table> | |
<thead> | |
<tr> | |
<!-- percorrer cada coluna --> | |
<th *ngFor="let coluna of colunas" class="{{ coluna.classeCssCabecalho }}" > | |
{{ coluna.cabecalho }} | |
</th> | |
</tr> | |
</thead> | |
<tbody> | |
<!-- percorrer cada linha --> | |
<ng-container *ngFor="let linha of linhas"> | |
<!-- Em breve iremos criar o componente que representa cada linha --> | |
<linha-tabela-aninhada | |
[linha]="linha" | |
[colunas]="colunas" | |
[extratorDeFilhos]="extratorDeFilhos" | |
[extratorDeClasseCss]="extratorDeClasseCss" ></linha-tabela-aninhada> | |
</ng-container> | |
</tbody> | |
</table> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table { | |
width: 100%; | |
border-spacing: 0; | |
} | |
td { | |
border-top: 1px solid white; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Input, OnInit } from '@angular/core'; | |
import { ColunaTabelaAninhada } from './coluna-tabela-aninhada'; | |
@Component({ | |
selector: 'tabela-aninhada', | |
templateUrl: './tabela-aninhada.component.html', | |
styleUrls: ['./tabela-aninhada.component.scss'] | |
}) | |
export class TabelaAninhadaComponent { | |
/** | |
* Informe as colunas da sua tabelas | |
*/ | |
@Input() | |
colunas: ColunaTabelaAninhada[] = []; | |
/** | |
* Informe o array de dados da sua tabela, onde cada elemento será um linhas da tabela | |
*/ | |
@Input() | |
linhas: any[] = []; | |
/** | |
* Informe a função para extrair, de cada linha, as linhas filhas. | |
*/ | |
@Input() | |
extratorDeFilhos: (linha: any) => any[] = (_:any) => null; | |
/** | |
* Informe a função para extrair, de cada linha, a classe de css customizada | |
*/ | |
@Input() | |
extratorDeClasseCss: (nivel) => string; | |
constructor() { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment