0

I am using PrimeNG datatable for the grid data, I would like to order the date column by descending order.

Tried using sortBy & sortOrder attributes from dataTable, but nothing works for me.

my code below:

    <p-dataTable [value]="dataList"
    sortMode="single"
    reorderableColumns="true"
    [globalFilter]="gbs"
    [responsive]="true"
    [rows]="10"
    [paginator]="true">
        <p-column field="firstName" header="FirstName" [sortable]="true">
            <ng-template let-row="rowData" pTemplate type="body">
                <strong>{{row.firstName}}</strong>
            </ng-template>
        </p-column>
        <p-column field="lastName" header="lastName" [sortable]="true">
            <ng-template let-row="rowData" pTemplate type="body">
                <strong>{{row.lastName}}</strong>
            </ng-template>
        </p-column>
        <p-column field="age" header="age" [sortable]="true">
            <ng-template let-row="rowData" pTemplate type="body">
                <strong>{{row.age}}</strong>
            </ng-template>
        </p-column>
        <p-column field="date" header="date" [sortable]="true">
            <ng-template let-row="rowData" pTemplate type="body">
                <strong>{{row.date}}</strong>
            </ng-template>
        </p-column>
</p-dataTable>

Need some spark to move forward... Thanks

Antikhippe
  • 6,316
  • 2
  • 28
  • 43
Ramkumar
  • 446
  • 1
  • 14
  • 30
  • i would suggest you to upgrade to the new tubro table if possible. way more performant and easier to handle. I'm dont sure how you fix this with the old table but turbo table got the following attributes: `sortField="date" sortOrder="-1"` – marvstar Dec 05 '18 at 14:34
  • Working Fine...Thanks.. – Ramkumar Dec 05 '18 at 15:07

0 Answers0