Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@deliverysolutions/ng-datatable

DataTable component for Angular framework

angular, angular15, angularcli, ivy, ng, ng2, ngx, table, pagination, sort, sorting

readme

Table component with sorting and pagination for Angular

It is a forked version of ng-datatable, updated to Angular 15, using Feather icons instead of Glyphicon for showing sorting arrows.

IMPORTANT

I am currently using custom CSS, to transform the fe-code icon 90 degrees as the default sort icon, and bolded + black chevron up & down icons accordingly. When feather releases their sort icons (should be soon, going by the related issues), will update the package to use those instead of the current patchwork.

Add below to your CSS theme.

.fe-bold {
  /* use !important to prevent issues with browser extensions that change fonts */
  font-family: 'Feather' !important;
  speak: none;
  font-style: normal;
  font-weight: bold;
  font-variant: normal;
  text-transform: none;
  line-height: 1;

  /* Better Font Rendering =========== */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.fe-bold-transform90 {
  /* use !important to prevent issues with browser extensions that change fonts */
  font-family: 'Feather' !important;
  speak: none;
  font-style: normal;
  font-weight: bold;
  font-variant: normal;
  text-transform: none;
  line-height: 1;

  /* Better Font Rendering =========== */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Transform 90 degrees, specifically for fe-code for sorting */
  -webkit-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  -o-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  transform: rotate(90deg);
  display: inline-block;
}
.fe-bold-black {
  /* use !important to prevent issues with browser extensions that change fonts */
  font-family: 'Feather' !important;
  speak: none;
  font-style: normal;
  font-weight: bold;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  color: black;

  /* Better Font Rendering =========== */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

Installation

npm i @deliverysolutions/ng-datatable --save

Usage example

AppModule.ts

import {NgModule} from "@angular/core";
...
import {DataTableModule} from "@deliverysolutions/ng-datatable";

@NgModule({
    imports: [
        ...
        DataTableModule
    ],
    ...
})
export class AppModule {

}

AppComponent.html

<table class="table table-striped" [mfData]="data" #mf="mfDataTable" [mfRowsOnPage]="5">
    <thead>
    <tr>
        <th style="width: 20%">
            <mfDefaultSorter by="name">Name</mfDefaultSorter>
        </th>
        <th style="width: 50%">
            <mfDefaultSorter by="email">Email</mfDefaultSorter>
        </th>
        <th style="width: 10%">
            <mfDefaultSorter by="age">Age</mfDefaultSorter>
        </th>
        <th style="width: 20%">
            <mfDefaultSorter by="city">City</mfDefaultSorter>
        </th>
    </tr>
    </thead>
    <tbody>
    <tr *ngFor="let item of mf.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">
            <mfBootstrapPaginator [rowsOnPageSet]="[5,10,25]"></mfBootstrapPaginator>
        </td>
    </tr>
    </tfoot>
</table>

API

mfData directive

  • selector: table[mfData]
  • exportAs: mfDataTable
  • inputs
    • mfData: any[] - array of data to display in table
    • mfRowsOnPage: number - number of rows should be displayed on page (default: 1000)
    • mfActivePage: number - page number (default: 1)
    • mfSortBy: any - sort by parameter
    • mfSortOrder: "asc" | "desc" - sort order parameter
  • outputs
    • mfSortByChange: any - sort by parameter
    • mfSortOrderChange: any - sort order parameter

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

changelog

Changelog

15.1.2 (2023-04-24)

Changes

  • Update dependencies to latest, fixes security alert

15.1.1 (2023-02-18)

Changes

  • Update dependencies to latest (closes #13)

15.1.0 (2022-11-28)

Changes

  • Not not throw runtime error if sortBy is undefined (thanks @alexkushnarov)

15.0.0 (2022-11-28)

Changes

  • Use Angular 15

14.0.1 (2022-10-15)

Changes

  • Minor dependency upgrades
  • Adjust linting configuration

14.0.0 (2022-06-19)

Changes

  • Use Angular 14

This update seems to have changed the behaviour of the change detection, if you notice any unexpected behaviour please open a new issue.

13.1.0 (2022-02-05)

Changes

  • Consistently sort nullish values (#8) (Changed behaviour)

This release fixes the very strange null sorting behaviour. Null values are now treated like empty strings and are placed at the top when sorting ascendingly.

13.0.0 (2021-11-10)

Changes

  • Use Angular 13

12.0.1 (2020-11-23)

Changes:

  • Use Angular 12
  • Sort headers are now 508 compliant and are usable by keyboard (Thanks @kvbutler)
  • Publish in partial-ivy support - Angular ivy compiler required
  • Stricter type declarations to prevent surprising runtime errors

11.1.0 (2020-11-23)

Changes:

- Remove dependency to lodash

11.0.1 (2020-11-23)

Changes:

- Specify correct peer dependency version

11.0.0 (2020-11-15)

Changes:

- Use Angular 11

10.0.0 (2020-06-27)

Changes:

- Use Angular 10

9.0.1 (2019-11-06)

Changes:

- Use Angular 9
- Use Angular CLI for build pipeline
- Fix some linting issues

8.0.0 (2019-11-06)

Changes:

- Use Angular 8

2.0.0 (2018-07-10)

Changes:

- Published as package @pascalhonegger/ng-datatable
- Use Angular 7

0.7.3 (2018-10-04)

Changes:

- Security updates in dependencies.

0.7.2 (2018-10-03)

Changes:

- Updated examples dependencies. (Thanks to @PascalHonegger)

0.7.1 (2018-10-03)

Changes:

- Angular and RxJS get updated to version 6 (see package.json). The only code changes include changes to systemjs.config and two import statements.
(Pull Request #3. Thanks to @PascalHonegger)

0.7.0 (2018-03-15)

Changes:

- First commit of forked project (@cmglez10/ng-datatable)
- Updated to Angular 5

0.6.0 (2017-03-27)

Fixes:

- fix AOT incompatibility, changing @angular dependencies to peerDependencies, thanks to @trevex (#91)

0.5.2 (2016-11-13)

Changes:

- added inputs/outputs for sorting (#14)

Bugfixes:

- detect changes in inputData array (#10)
- fixed detecting changes in mfRowsOnPage (#32)
- fixed support for AOT compilation

0.5.1 (2016-10-25)

Changes:

- changed the old "typings" system to the new "@types" system
- added support for AOT compilation

Bugfixes:

- sorting by child properties (#41)

0.5.0 (2016-10-09)

Breaking changes:

- update angular library to 2.0.0

Bugfixes:

- sort case insensitive
- fixed pagination, fix #29, #33

Changelog

0.4.2 (2016-05-11)

Breaking changes:

- update angular library to 2.0.0-rc.0

0.3.0 (2016-05-08)

Breaking changes:

- move `rowsOnPage` and `activePage` input from BootstrapPaginator to DataTable directive

Bugfixes:

- fix error when mfData input is undefined
- add src so map files should have correct paths

0.2.5 (2016-04-19)

Bugfixes:

- fix not visible paginator

0.2.4 (2016-04-19)

Bugfixes:

- add import for lodash in file `DataTable.ts`

0.2.3 (2016-03-21)

Bugfixes:

- remove `href` attribute from DefaultSorter
- add style `cursor: pointer` to links in DefaultSorter and BootstrapPaginator

0.2.2 (2016-03-21)

Bugfixes:

- remove `href` attribute from BootstrapPaginator template