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
4 changes: 4 additions & 0 deletions src/js/core/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
F11: 122,
F12: 123
},
keyCombination: {
SHIFT: 1,
CTRL: 2
},
/**
* @ngdoc object
* @name ASC
Expand Down
7 changes: 5 additions & 2 deletions src/js/core/directives/ui-grid-header-cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,12 @@
$scope.$on( '$destroy', dataChangeDereg );

$scope.handleClick = function(event) {
// If the shift key is being held down, add this column to the sort
// If the a specific key is being held down, add this column to the sort
var add = false;
if (event.shiftKey) {
var useShift = uiGridCtrl.grid.options.keyToAddSortColumns & uiGridConstants.keyCombination.SHIFT;
var useCtrl = uiGridCtrl.grid.options.keyToAddSortColumns & uiGridConstants.keyCombination.CTRL;

if ((event.shiftKey && useShift) || (event.ctrlKey && useCtrl)) {
add = true;
}

Expand Down
9 changes: 9 additions & 0 deletions src/js/core/factories/GridOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,15 @@ angular.module('ui.grid')
*/
baseOptions.appScopeProvider = baseOptions.appScopeProvider || null;

/**
* @ngdoc object
* @name keyToAddSortColumns
* @propertyOf ui.grid.class:GridOptions
* @description this option specifies whether the adding of columns to the collection of sorted columns is enabled by pressing
* the shift key, the control key or either. This option takes any binary OR combination of SHIFT and CTRL from uiGridConstants.keyCombination.
*/
baseOptions.keyToAddSortColumns = baseOptions.keyToAddSortColumns || uiGridConstants.keyCombination.SHIFT;

return baseOptions;
}
};
Expand Down
15 changes: 10 additions & 5 deletions test/unit/core/factories/GridOptions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ describe('GridOptions factory', function () {
gridFooterTemplate: 'ui-grid/ui-grid-grid-footer',
rowTemplate: 'ui-grid/ui-grid-row',
gridMenuTemplate: 'ui-grid/uiGridMenu',
appScopeProvider: null
appScopeProvider: null,
keyToAddSortColumns: 1
});
});

Expand Down Expand Up @@ -99,7 +100,8 @@ describe('GridOptions factory', function () {
rowTemplate: 'testRow',
gridMenuTemplate: 'testGridMenu',
extraOption: 'testExtraOption',
appScopeProvider : 'anotherRef'
appScopeProvider : 'anotherRef',
keyToAddSortColumns: 3
};
expect( GridOptions.initialize(options) ).toEqual({
onRegisterApi: testFunction,
Expand Down Expand Up @@ -143,7 +145,8 @@ describe('GridOptions factory', function () {
rowTemplate: 'testRow',
gridMenuTemplate: 'testGridMenu',
extraOption: 'testExtraOption',
appScopeProvider : 'anotherRef'
appScopeProvider : 'anotherRef',
keyToAddSortColumns: 3
});
});

Expand Down Expand Up @@ -189,7 +192,8 @@ describe('GridOptions factory', function () {
gridFooterTemplate: 'testGridFooter',
rowTemplate: 'testRow',
gridMenuTemplate: 'testGridMenu',
extraOption: 'testExtraOption'
extraOption: 'testExtraOption',
keyToAddSortColumns: 1
};
expect( GridOptions.initialize(options) ).toEqual({
onRegisterApi: testFunction,
Expand Down Expand Up @@ -233,7 +237,8 @@ describe('GridOptions factory', function () {
rowTemplate: 'testRow',
gridMenuTemplate: 'testGridMenu',
extraOption: 'testExtraOption',
appScopeProvider : null
appScopeProvider : null,
keyToAddSortColumns: 1
});
});
});
Expand Down