-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* docs: add example img of custom row on table docs #738 * feat: add required to chip-group #734 * docs: add example img of custom row on table docs #738 * fix: documentation problem #738 --------- Co-authored-by: Iury Nogueira <[email protected]>
- Loading branch information
1 parent
667438f
commit 4ab73c5
Showing
3 changed files
with
71 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Canvas, Meta, Story } from '@storybook/addon-docs'; | ||
import imageExaple from './assets/table-custom-row.png'; | ||
|
||
<Meta | ||
title="Ion/Data Display/Table Custom Row" | ||
component={IonSmartTableComponent} | ||
/> | ||
|
||
export const Template = (args) => <IonSmartTableComponent {...args} />; | ||
|
||
## Table Custom Row | ||
|
||
Passos para customizar a linha da tabela. | ||
|
||
1. No HTML do seu componente, crie um ng-template com a diretiva 'let-row' e realize as customizações desejadas. A diretiva 'let-row' permite acessar os dados da linha através da identificação do objeto passado na configuraçãoda tabela. Veja o exemplo abaixo: | ||
|
||
```html | ||
<ng-template #customTemplate let-row> | ||
<td>{{row.id}}</td> | ||
<td>{{ row.name }}</td> | ||
<td><ion-icon [type]="row.active ? 'check' : 'close'"></ion-icon></td> | ||
<td> | ||
<ion-icon | ||
type="info" | ||
(click)="onDetails(row)" | ||
style="cursor: pointer" | ||
></ion-icon> | ||
</td> | ||
</ng-template> | ||
``` | ||
|
||
2. No arquivo .ts do seu componente, utilize o decorator '@ViewChild' para obter a referência do template customizado criado no arquivo HTML: | ||
|
||
```ts | ||
export class AppComponent implements OnInit { | ||
@ViewChild("customTemplate", { static: true }) | ||
customTemplate: TemplateRef<HTMLElement>; | ||
|
||
... | ||
} | ||
``` | ||
|
||
3. Passe a referência do template customizado para o atributo customRowTemplate da configuração da tabela: | ||
|
||
```ts | ||
export class AppComponent implements OnInit { | ||
... | ||
|
||
ngOnInit(): void { | ||
this.config = { | ||
data, | ||
columns, | ||
customRowTemplate: this.customTemplate, | ||
} | ||
} | ||
} | ||
``` | ||
|
||
4. Pronto! A linha da tabela será customizada de acordo com o template criado. Veja o exemplo abaixo: | ||
|
||
<img src={imageExaple} alt="grid 1" /> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.