Skip to content
Pablo Aragón edited this page May 31, 2019 · 6 revisions

This component allows you to activate sort functionality. When it is active, user can click on table headers and an event will be fired.

This event contains info about what header has been clicked and the direction to order.

To enable sorting, you have to change the config variable sort.enable to true.

<!-- your component.html -->
<ngx-table [data]="exampleData" [config]="config" (sort)="onSort($event)"></ngx-table>
// your component.ts

config: NgxTableConfig = {
    sort: {
      enable: true
    },
    ...
};

...

onSort(order: NgxTableOrder) {
 // your sort logic
}

The sort event, pass as parameter the following interface

interface NgxTableOrder {
    field: string;
    direction: 1 | -1;
}
Clone this wiki locally