I'm submitting a ...
[x] bug report
Plunkr Case (Bug Reports)
https://stackblitz.com/edit/github-8bsq6q
Current behavior
When we specify a default sorting order for a p-table using sortOrder property, the default sorting icon is not displayed once the table loads. Although the data is sorted correctly and the column is highlighted properly, the sorting icon is not displayed to indicate the sortOrder (i.e. ascending or descending). If I click to reorder it, then it appears. Note that when sortOrder is NOT specified in the HTML, the icon appears correctly (sorted in ascending order which is the default).
Expected behavior
The sort-down or sort-up icons should be visible at first to indicate the default sort order, as specified.
Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/github-8bsq6q
Angular version: 6.1.7
PrimeNG version: 6.1.3
Browser: Tested in Chrome, Firefox, Edge
Language: Typescript 2.9.2
Node (for AoT issues): node --version = 8.12.0
Hi,
Can you try this
<p-table sortField="name" [sortOrder]="-1">
<ng-template pTemplate="header">
<tr>
<th [pSortableColumn]="'name'" pResizableColumn>Name<p-sortIcon [field]="'name'"></p-sortIcon>
</th>
<th [pSortableColumn]="'age'" pResizableColumn>Age<p-sortIcon [field]="'age'"></p-sortIcon>
</th>
<th [pSortableColumn]="'date'" pResizableColumn>Date<p-sortIcon [field]="'date'"></p-sortIcon>
</th>
</tr>
</ng-template>
</p-table>
Yes, this resolves the issue. I could never figure it out. Probably the documentation needs to be modified though.
Thanks Yigit!
Most helpful comment
Hi,
Can you try this