angular-datatables icon indicating copy to clipboard operation
angular-datatables copied to clipboard

how to sort column by date

Open anasahmedtaj opened this issue 2 years ago • 0 comments

Hi i want to sort the column 2 by date in dd-mm-yyyy format in angular 12 (typescript)

Here's my html

<table datatable [dtOptions]="dtOptions" class="row-border hover">
            <thead>
                <tr>
                    <th>Sr.</th>
                    <th>Customers</th>
                    <th>Created on</th>
                    <th>Request/min</th>
                    <th>Request/day</th>
                    <th>Per Request URL</th>
                    <th>status</th>
                </tr>
            </thead>
            <tbody>
                <ng-container *ngFor="let items of customerListTabelData; let i = index">
                    <tr (click)="changeRoute(items.name)">
                        <td>{{i+1}}</td>
                        <td>{{items.name}}</td>
                        <td>{{items.createdAt ? items.createdAt : 'N/A'}}</td>
                        <td>{{items.per_min}}</td>
                        <td>{{items.per_day}}</td>
                        <td>{{items.per_req_url}}</td>
                        <td [ngClass]="items.status">{{items.status}}</td>
                    </tr>
                </ng-container>
            </tbody>
</table>

and my typescript

ngOnInit(): void {
  this.dtOptions = {
    pagingType: 'full_numbers',
    language : {
      paginate : {
        first : "First",
        last : "Last",
        next : "&#9654;",
        previous : "&#9664"
      },
      searchPlaceholder: "Search with Customer Name",
    },
    columnDefs: [
      { targets: 2, type: 'date'},
    ]
  };
  this.getCustomers()
}

but this doesn't seem to work.

anasahmedtaj avatar Oct 10 '22 15:10 anasahmedtaj