Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fr-data-table): Add (dataTableAction) and deprecate some output …
…events
- Loading branch information
Showing
4 changed files
with
82 additions
and
39 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
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 |
---|---|---|
@@ -1,50 +1,63 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
import { FrDataTableEvent } from '../app/data-table/data-table/data-table.component'; | ||
|
||
@Component({ | ||
selector: 'data-table-demo', | ||
template: ` | ||
<fr-data-table [selectable]="true"> | ||
<fr-data-table-header title="Header" | ||
(updateAction)="updateAction($event)" | ||
[otherActionKeys]="dataTableOtherActionKeys" | ||
(otherAction)="otherAction($event)"></fr-data-table-header> | ||
<fr-data-table-columns [columns]="columns"></fr-data-table-columns> | ||
<fr-data-table-rows [rows]="rows"></fr-data-table-rows> | ||
<fr-data-table-footer | ||
[paginationInfo]="{ totalRows: 100, rowsPerPageValues: [10, 30, 50], page: 1, rowsPerPage: 30 }" | ||
(paginationAction)="paginationAction($event)"></fr-data-table-footer> | ||
<!-- Table Container --> | ||
<fr-data-table | ||
[selectable]="dataTableInfo.selectable" | ||
[sortable]="dataTableInfo.sortable" | ||
(dataTableAction)="dataTableAction($event)"> | ||
<!-- Header component which contains title and action buttons --> | ||
<fr-data-table-header [title]="dataTableInfo.title" [otherActionKeys]="dataTableInfo.actionKeys"></fr-data-table-header> | ||
<!-- Define columns --> | ||
<fr-data-table-columns [columns]="dataTableInfo.columns"></fr-data-table-columns> | ||
<!-- Set Data rows --> | ||
<fr-data-table-rows [rows]="dataTableInfo.rows"></fr-data-table-rows> | ||
<!-- Footer component which contains pagination info and actions --> | ||
<fr-data-table-footer [paginationInfo]="dataTableInfo.paginationInfo" ></fr-data-table-footer> | ||
</fr-data-table> | ||
` | ||
}) | ||
export class DataTableDemoComponent { | ||
|
||
dataTableOtherActionKeys = [ | ||
{ key: 'action1', label: 'Action1' }, | ||
{ key: 'action2', label: 'Action2' } | ||
]; | ||
columns = [ | ||
{ key: 'column1', name: 'Column1 (number)', type: 'number' }, | ||
{ key: 'column2', name: 'Column2 (string)', type: 'string' }, | ||
{ key: 'column3', name: 'Column3 (number)', type: 'number' }, | ||
{ key: 'column4', name: 'Column4 (string)', type: 'string' }, | ||
{ key: 'column5', name: 'Column5 (number)', type: 'number' } | ||
]; | ||
rows = [ | ||
{ column1: 1, column2: 'value1', column3: 100, column4: '2017-03-01 00:00:00', column5: 999 }, | ||
{ column1: 2, column2: 'value2', column3: 100, column4: '2017-03-01 00:00:00', column5: 987 }, | ||
{ column1: 3, column2: 'value3', column3: 100, column4: '2017-03-01 00:00:00', column5: 989 } | ||
]; | ||
|
||
public updateAction(event) { | ||
console.log(event); | ||
} | ||
|
||
public otherAction(event) { | ||
console.log(event); | ||
} | ||
public dataTableInfo = { | ||
selectable: true, | ||
sortable: true, | ||
title: 'DataTableTitle', | ||
actionKeys: [ | ||
{ key: 'action1', label: 'Action1' }, | ||
{ key: 'action2', label: 'Action2' }, | ||
{ key: 'action3', label: 'Action3-has-long-keys' } | ||
], | ||
columns: [ | ||
{ key: 'column1', name: 'Column1 (number)', type: 'number' }, | ||
{ key: 'column2', name: 'Column2 (string)', type: 'string' }, | ||
{ key: 'column3', name: 'Column3 (number)', type: 'number' }, | ||
{ key: 'column4', name: 'Column4 (string)', type: 'string' }, | ||
{ key: 'column5', name: 'Column5 (number)', type: 'number' } | ||
], | ||
rows: [ | ||
{ column1: 1, column2: 'value1', column3: 100, column4: '2017-03-01 00:00:00', column5: 999 }, | ||
{ column1: 2, column2: 'value2', column3: 100, column4: '2017-03-01 00:00:00', column5: 987 }, | ||
{ column1: 3, column2: 'value3', column3: 100, column4: '2017-03-01 00:00:00', column5: 989 } | ||
], | ||
paginationInfo: { | ||
totalRows: 100, | ||
rowsPerPageValues: [10, 30, 50], | ||
page: 1, | ||
rowsPerPage: 30 | ||
} | ||
}; | ||
|
||
public paginationAction(event) { | ||
console.log(event); | ||
public dataTableAction($event: FrDataTableEvent) { | ||
console.log($event); | ||
} | ||
|
||
} |