Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/js/core/directives/ui-grid-column-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,23 @@ function ( i18nService, uiGridConstants, gridUtil ) {

},

/**
* @ngdoc method
* @methodOf ui.grid.service:uiGridColumnMenuService
* @name suppressSort
* @description determines whether we should suppress the sort asc/desc options
* @param {$scope} $scope the $scope from the uiGridColumnMenu
*
*/
suppressSort: function( $scope ) {
if ($scope.col && $scope.col.colDef && $scope.col.colDef.suppressSort) {
return true;
}
else {
return false;
}
},

/**
* @ngdoc method
* @methodOf ui.grid.service:uiGridColumnMenuService
Expand Down Expand Up @@ -169,7 +186,7 @@ function ( i18nService, uiGridConstants, gridUtil ) {
$scope.sortColumn($event, uiGridConstants.ASC);
},
shown: function () {
return service.sortable( $scope );
return service.sortable( $scope ) && !service.suppressSort( $scope );
},
active: function() {
return service.isActiveSort( $scope, uiGridConstants.ASC);
Expand All @@ -183,7 +200,7 @@ function ( i18nService, uiGridConstants, gridUtil ) {
$scope.sortColumn($event, uiGridConstants.DESC);
},
shown: function() {
return service.sortable( $scope );
return service.sortable( $scope ) && !service.suppressSort( $scope );
},
active: function() {
return service.isActiveSort( $scope, uiGridConstants.DESC);
Expand Down
14 changes: 14 additions & 0 deletions test/unit/core/directives/ui-grid-column-menu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ describe('ui-grid-column-menu uiGridColumnMenuService', function () {
});
});

describe('suppressSort: ', function () {
it('everything present: is suppressed', function () {
$scope.col = { uid: 'ui-grid-01x', colDef: { suppressSort: true } };

expect( uiGridColumnMenuService.suppressSort( $scope ) ).toEqual( true );
});

it('colDef missing: is not suppressed', function () {
$scope.col = { uid: 'ui-grid-01x' };

expect( uiGridColumnMenuService.suppressSort( $scope ) ).toEqual( false );
});
});


describe('hideable: ', function () {
it('everything present: is not hideable', function () {
Expand Down