1
我需要做一個多列排序。它必須是「高(紅色 - 不例子,因爲它是一個零計數)」,「中(橙色)」,「低(黃色)」 ..像下面的圖片..獨特的多列排序角js
然而,當我使用角JS排序,我得到以下..
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.patients的
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
}
不清楚什麼樣的數據實際上是被排序或你打算如何管理這些。 [plunker](http://plnkr.co/edit/?p=catalogue)中的簡化演示將有助於 – charlietfl
每個對象中有3列稱爲'AlertHighCount','AlertMediumCount','AlertLowCount'。默認情況下,我需要先按高,然後中,然後再按低排序。在上面的例子中,High缺失是因爲當計數爲零時隱藏它。不幸的是,它是我必須處理的唯一示例數據。如果您查看第一個圖像,則會看到它先排列中等,然後是低。第二個圖像是排序我上面的代碼正在返回.. – dave
不難從瀏覽器開發工具網絡複製數據示例或將字符串化對象記錄到控制檯。我們無法操縱圖像。您可能需要在'vm.setSortType'中定義一個對象 – charlietfl