我需要进行多列排序。它必须是"高(红色 - 不是示例,因为它是零计数)","中(橙色)","低(黄色) " ..如下图所示..
然而,当我使用Angular JS Sorting时,我得到以下内容..
纳克重复
<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)">
单击列标题时。
<th ng-click="vm.setSortType('')">
<span>
Other Alerts
<i class="fa fa-sort"></i>
</span>
</th>
setSortType函数......
vm.setSortType = function (sortType) {
vm.tableParams.sortReverse = !vm.tableParams.sortReverse;
if (sortType == '') {
vm.tableParams.sortType = "['AlertHighCount', 'AlertMediumCount', 'AlertLowCount']";
return;
}
vm.tableParams.sortType = sortType;
}
vm.patients的示例数据。 AlertHighCount将首先是AlertMediumCOunt,然后是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
}
答案 0 :(得分:2)
您希望orderby参数为数组而不是字符串
尝试
vm.tableParams.sortType = ['AlertHighCount', 'AlertMediumCount', 'AlertLowCount'];