We have a PrimeNg data file that has several columns (like most of them), we should be able to have multiple views when the user clicks on one of the three columns, but this column is only the first of two fields that it should be sorted. The second field is a hidden field that will always be sorted by ASC.
We tried to use multiservice, multisort and sortfunctions, but cannot make it work correctly. A web search could only find one example of the sortFunction function, but it is only for one field.
Here is an example installation from a storefront, with the indicated multi-line files.
<p-dataTable [value]="cars" multiSortMeta="multiSortMeta">
<p-column field="vin" header="Vin"></p-column>
<p-column field="year" header="Year"></p-column>
<p-column field="brand" header="Brand" (sortFunction)="mySort($event)"></p-column>
<p-column field="color" header="Color" (sortFunction)="mySort($event)"></p-column>
</p-dataTable>
How would you write the mySort function and / or modify the definition of dataTable to allow the user to click on the Color or Brand columns and sort them by this field first, and the Year second field?
Any help would be greatly appreciated since we are finally trying to get it to work.
Billf source
share