ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Initializing multi-column sort via sortInfo broken

Open floyd-may opened this issue 13 years ago • 4 comments

(using version 2.0.7)

If you attempt to initialize a multi-column sort via passing sortInfo in the grid options, the sort priority indicators do not appear, and it does not appear to sort in the proper order. I was able to work around this via a plugin:

/* inside gridOptions */
plugins: [{

    init: function (scope, grid) {

        var sortInfo = [
            { field: 'fieldOne', direction: 'asc' },
            { field: 'fieldTwo', direction: 'desc' }
        ]

        var sortColumns = _.map(sortInfo, function(fieldAndDirection) {
            return _.find(scope.columns, function (col) {
                if (col.field === fieldAndDirection.field) {
                    col.sortDirection = fieldAndDirection.direction;
                    return true;
                }

                return false;
            });
        });

        grid.sortData(sortColumns);
    }
}]

The problem appears to be inside the sortColumnsInit function, where, rather than passing the entire set of columns to sortData, it passes them one at a time. This also may be related to https://github.com/angular-ui/ng-grid/issues/732. It seems strange that we would pass instances of ngColumn in the sortInfo, which should be built on our behalf.

floyd-may avatar Oct 02 '13 14:10 floyd-may

:+1: (btw, haven't tried your workaround -- do you have a jsfiddle for it? Thx!)

carueda avatar Feb 04 '14 16:02 carueda

Here it is broken; notice that the numeric indicators on the columns aren't there. You can't tell (from the indicators) which column is sorted first.

I'm having trouble getting my workaround to function properly; I'm learning that not all 2.0.7 builds are created equal =(

floyd-may avatar Feb 05 '14 18:02 floyd-may

This appears to be have been fixed in 2.0.8!

fleshins avatar Mar 15 '14 23:03 fleshins

Any idea when the next release will be? Thanks for all the awesome work.

EricBichara avatar Apr 16 '14 14:04 EricBichara