-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Pablo Aragón edited this page May 20, 2019
·
18 revisions
This library offers an Angular component that allows you to display your data in a table.
This table handles different events that can be implemented by the developers that use it.
The events are the following:
npm install --save @paaragon/ngx-table
[WIP]
// component.ts
const exampleData: any[] = [
{ name: 'Delbert', lastname: 'Keeling', birthdate: new Date(1990, 1, 21), company: 'Gislason, Braun and Kerluke', salary: 30432 },
{ name: 'Karine', lastname: 'Rice', birthdate: new Date(1982, 3, 1), company: 'Thiel - Connelly', salary: 29188 },
{ name: 'Rachelle', lastname: 'Flatley', birthdate: new Date(1985, 10, 16), company: 'Bradtke, Donnelly and Gottlieb', salary: 27026 },
{ name: 'Gardner', lastname: 'Lindgren', birthdate: new Date(1982, 9, 20), company: 'Crist - Klein', salary: 52676 }
];
<!-- component.html -->
<ngx-table [data]="exampleData"></ngx-table>
<!-- your compo -->
<ngx-table [data]="exampleData" (sort)="onSort($event)"></ngx-table>
// your component.ts
onSort(order: NgxTableOrder) {
// your logic
}
interface NgxTableOrder {
field: string;
direction: 1 | -1;
}
<ngx-table [data]="exampleData" (filter)="onFilter($event)"></ngx-table>
Emitted type
interface NgxTableFilter {
[key: string]: { operator: NgxTableOperator, value: string };
}
[WIP]
[WIP]
[WIP]
[WIP]
You can provide a config object to customize your table.
<!-- your component.html -->
<ngx-table [data]="exampleData" [config]="config"></ngx-table>
// Config interface
export interface NgxTableConfig {
placeholders?: NgxTablePlaceholders;
sort?: {
enable?: boolean
};
filter?: {
enable: boolean,
debounceTime?: number,
validations?: {
[key: string]: {
regex: string,
errorMsg: string
}
},
lock?: string[],
operators?: NgxTableOperator[]
};
create?: {
enable: boolean,
validations?: {
[key: string]: {
regex: string,
errorMsg: string
}
},
lock?: string[]
};
delete?: {
enable: boolean
};
edit?: {
enable: boolean,
longContent?: number,
lock?: string[]
};
}