gpt4 book ai didi

javascript - 独特的多列排序angular js

转载 作者:行者123 更新时间:2023-11-30 16:14:28 25 4
gpt4 key购买 nike

我需要进行多列排序。它需要是“高(红色 - 不在示例中,因为它是零计数)”,“中(橙色)”,“低(黄色)”.. 如下图所示..

Correct Sorting

但是,当我使用 Angular JS 排序时,我得到以下结果..

incorrect 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 &nbsp;
<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
}

最佳答案

您希望 orderby 参数是一个数组而不是一个字符串

尝试

vm.tableParams.sortType = ['AlertHighCount', 'AlertMediumCount', 'AlertLowCount'];

关于javascript - 独特的多列排序angular js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35730381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com