[英]unique multi-column sorting angular js
我需要進行多列排序。 如下圖所示,它必須是“高(紅色-不為零,因為它是零計數)”,“中(橙色)”,“低(黃色)” ..
但是,當我使用Angular JS Sorting時,得到以下內容。
NG-重復
<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;
}
虛擬機患者的樣本數據。 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
}
您希望orderby參數是數組而不是字符串
嘗試
vm.tableParams.sortType = ['AlertHighCount', 'AlertMediumCount', 'AlertLowCount'];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.