Reputation: 205
I need to do a multiple column sort. It needs to be "High (Red - Not in example because it's a zero count)", "Medium (Orange)", "Low (Yellow)".. like the image below..
However, when I use Angular JS Sorting, I get the following..
ng-repeat
<tr ng-repeat="pat in vm.patients.slice(((vm.tableParams.currentPage-1)*vm.tableParams.pageSize), ((vm.tableParams.currentPage)*vm.tableParams.pageSize)) | orderBy:vm.tableParams.sortType:vm.tableParams.sortReverse track by $index" ng-click="vm.showPatientDetail(pat.PatientNum)">
When the column header is clicked.
<th ng-click="vm.setSortType('')">
<span>
Other Alerts
<i class="fa fa-sort"></i>
</span>
</th>
The setSortType function...
vm.setSortType = function (sortType) {
vm.tableParams.sortReverse = !vm.tableParams.sortReverse;
if (sortType == '') {
vm.tableParams.sortType = "['AlertHighCount', 'AlertMediumCount', 'AlertLowCount']";
return;
}
vm.tableParams.sortType = sortType;
}
sample data of vm.patients. The AlertHighCount would be first, AlertMediumCOunt, then AlertLowCount
{
"PatientNum": 56,
"LastName": "Patient",
"FirstName": "Demo",
"PatientName": "Patient, Demo",
"PatientBirthDate": "1942-12-12T00:00:00",
"PrescribePhys": 0,
"PhysicianFirstName": null,
"PhysicianLastName": null,
"TreatmentCount": 0,
"AlertHighCount": 1,
"AlertMediumCount": 2,
"AlertLowCount": 0,
"AlertLevel": 0,
"DeviceType": 1,
"PMSPatient": 0
},
{
"PatientNum": 727,
"LastName": "cat",
"FirstName": "cat",
"PatientName": "cat, cat",
"PatientBirthDate": null,
"PrescribePhys": 0,
"PhysicianFirstName": null,
"PhysicianLastName": null,
"TreatmentCount": 0,
"AlertHighCount": 0,
"AlertMediumCount": 2,
"AlertLowCount": 1,
"AlertLevel": 0,
"DeviceType": 1,
"PMSPatient": 0
},
{
"PatientNum": 1036,
"LastName": "Cat",
"FirstName": "Cat",
"PatientName": "Cat, Cat",
"PatientBirthDate": null,
"PrescribePhys": 0,
"PhysicianFirstName": null,
"PhysicianLastName": null,
"TreatmentCount": 0,
"AlertHighCount": 0,
"AlertMediumCount": 1,
"AlertLowCount": 5,
"AlertLevel": 0,
"DeviceType": 1,
"PMSPatient": 0
},
{
"PatientNum": 1040,
"LastName": "Cat",
"FirstName": "Cat",
"PatientName": "Cat, Cat",
"PatientBirthDate": null,
"PrescribePhys": 0,
"PhysicianFirstName": null,
"PhysicianLastName": null,
"TreatmentCount": 0,
"AlertHighCount": 0,
"AlertMediumCount": 1,
"AlertLowCount": 3,
"AlertLevel": 0,
"DeviceType": 1,
"PMSPatient": 0
}
Upvotes: 1
Views: 188
Reputation: 171669
You are wanting the orderby parameter to be an array not a string
Try
vm.tableParams.sortType = ['AlertHighCount', 'AlertMediumCount', 'AlertLowCount'];
Upvotes: 2