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

javascript - 独特的多列排序 Angular js-LMLPHP

但是,当我使用Angular JS Sorting时,得到以下内容。

javascript - 独特的多列排序 Angular js-LMLPHP

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)">


单击列标题时。

<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;
    }


虚拟机患者的样本数据。 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'];

09-06 02:14