We have a PrimeNg datatable that has multiple columns (as most do), we need to be able to have a multiple sort happen when a user clicks on one of the 3 columns, but that column is only the first of two fields that it needs to sort on. The second field is a hidden field that will always be sorted ASC.
We have tried using multiSortMeta, multisort and sortfunctions, but are unable to get this working correct. Searching online, have only been able to find a single example of a sortFunction, but it is only for a single field.
Here is an example setup from the showcase, with some of the multisort stuff indicated.
<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 change the dataTable definition to allow the user to click on the Color or Brand columns and have it sort by that field first, and the Year field second?
Any help would be greatly appreciated, as we are at our wits end trying to get this to work.