过滤后的ui-grid排序数据

时间:2017-09-11 13:34:32

标签: javascript angularjs angular-ui-grid ui-grid

我的此模型包含用户选择语言的标签。

"status": [{
        "id": "IN_PROGRESS",
        "label": "In progress"
    }, {
        "id": "KO",
        "label": "Everything is KO"
    }, {
        "id": "OK",
        "label": "Everything is OK"
    }]

来自服务器的数据:

myService.data =[{
status:"OK",
history:"History 2"
},{
status:"IN_PROGRESS",
history:"History 3"
},{
status:"KO",
history:"History 4"
}
]

在我的控制器中,我有以下内容:

vm.myList = {
            enableColumnMenus: false,
            enableHorizontalScrollbar: 0,
            enableVerticalScrollbar: 0,
            enableRowSelection: false,
            enableRowHeaderSelection: false,
            multiSelect: false,
            paginationPageSizes: [6],
            paginationPageSize: 6,
            useExternalSorting: false,
            paginationTemplate: "views/templates/grid-custom-pager.html",
            columnDefs: [{
                    displayName: "recording.status",
                    field: 'status',
                    headerCellFilter: 'translate',
                    cellFilter: 'translate',
                    sortCellFiltered: true,
                    cellTemplate: '<div class="ui-grid-cell-contents" translate-field="status" translate-value="COL_FIELD"></div>'
                },
                {
                    displayName: "recording.history",
                    field: 'history',
                    headerCellFilter: 'translate'
}],
data: myService.data}

当我按标题单元格进行排序时,排序由字段值进行,而不是由显示的值进行。在完成过滤后,有没有办法对列进行排序?

1 个答案:

答案 0 :(得分:0)

您是否尝试过创建自己的排序算法?请参阅项目的维基页面Sorting in Ui-Grid