Table component with sorting and server pagination for Angular2
Demo
Check live demo in plunker
Installation
npm i -S angular2-serverpagination-datatable
Usage example
AppModule.ts
;...;
UserComponent.html
Name Email Age City x {{item.name}} {{item.email}} {{item.age}} {{item.city | uppercase}}
UserComponent.ts
ngOnInit: void public loadData public toIntnum: string public sortByWordLength = public removeitem public onPageChangeevent public onSortOrderevent
API
mfData
directive
- selector:
table[mfData]
- exportAs:
mfDataTable
- inputs
mfData: any[]
- array of data to display in tablemfRowsOnPage: number
- number of rows should be displayed on page (default: 1000)mfActivePage: number
- page number (default: 1)mfSortBy: any
- sort by parametermfSortOrder: string
- sort order parameter, "asc" or "desc"
- outputs
mfSortByChange: any
- sort by parametermfSortOrderChange: any
- sort order parametermfOnPageChange: any
- page change parameter(rowsOnPage,activePage)
mfDefaultSorter
component
- selector:
mfDefaultSorter
- inputs
by: any
- specify how to sort data (argument for lodash function _.sortBy )
mfBootstrapPaginator
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:
mfBootstrapPaginator
- inputs
rowsOnPageSet: number
- specify values for buttons to change number of diplayed rows