0.0.24 • Published 5 years ago
@aflorin11/data-table v0.0.24
Table component with sorting and pagination for Angular 7
It is a forked version of @abdulk1/angular-6-datatable.
Installation
npm i @aflorin11/data-table --save
Usage example
AppModule.ts
import {NgModule} from "@angular/core";
...
import {DataTableModule} from "@aflorin11/data-table";
@NgModule({
imports: [
...
DataTableModule
],
...
})
export class AppModule {
}
AppComponent.html
<table
class="table table-striped"
[afData]="data"
#af="afDataTable"
[afRowsOnPage]="5"
>
<thead>
<tr>
<th style="width: 20%">
<afDefaultSorter by="name">Name</afDefaultSorter>
</th>
<th style="width: 50%">
<afDefaultSorter by="email">Email</afDefaultSorter>
</th>
<th style="width: 10%">
<afDefaultSorter by="age">Age</afDefaultSorter>
</th>
<th style="width: 20%">
<afDefaultSorter by="city">City</afDefaultSorter>
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of af.data">
<td>{{item.name}}</td>
<td>{{item.email}}</td>
<td class="text-right">{{item.age}}</td>
<td>{{item.city | uppercase}}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">
<afBootstrapPaginator
[rowsOnPageSet]="[5,10,25]"
></afBootstrapPaginator>
</td>
</tr>
</tfoot>
</table>
API
afData
directive
- selector:
table[afData]
- exportAs:
afDataTable
- inputs
afData: any[]
- array of data to display in tableafRowsOnPage: number
- number of rows should be displayed on page (default: 1000)afActivePage: number
- page number (default: 1)afSortBy: any
- sort by parameterafSortOrder: string
- sort order parameter, "asc" or "desc"
- outputs
afSortByChange: any
- sort by parameterafSortOrderChange: any
- sort order parameter
afDefaultSorter
component
- selector:
afDefaultSorter
- inputs
by: any
- specify how to sort data (argument for lodash function _.sortBy )
afBootstrapPaginator
component
Displays buttons for changing current page and number of displayed rows using bootstrap template (css for bootstrap is required). If array length is smaller than current displayed rows on page then it doesn't show button for changing page. If array length is smaller than min value rowsOnPage then it doesn't show any buttons.
- selector:
afBootstrapPaginator
- inputs
rowsOnPageSet: number
- specify values for buttons to change number of diplayed rowsbuttons: object = { firstBtn: string, previousBtn: string, nextBtn: string, lastBtn: string }
- specify labels for first, previous, next and last buttons
0.0.24
5 years ago
0.0.23
5 years ago
0.0.22
5 years ago
0.0.21
5 years ago
0.0.20
5 years ago
0.0.19
5 years ago
0.0.18
5 years ago
0.0.16
5 years ago
0.0.15
5 years ago
0.0.14
5 years ago
0.0.13
5 years ago
0.0.12
5 years ago
0.0.11
5 years ago
0.0.10
5 years ago
0.0.9
5 years ago
0.0.8
5 years ago
0.0.7
5 years ago
0.0.6
5 years ago
0.0.5
5 years ago
0.0.4
5 years ago
0.0.3
5 years ago
0.0.2
5 years ago
0.0.1
5 years ago
0.0.0
5 years ago