Skip to content

Commit

Permalink
fix(grouping): grouping a pinned column was broken
Browse files Browse the repository at this point in the history
 If a pinned left column was grouped, the column was moved left of row headers
  • Loading branch information
swalters committed Jul 6, 2015
1 parent 448168b commit acb7e7b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/features/grouping/js/grouping.js
Expand Up @@ -615,13 +615,19 @@

columns.sort(function(a, b){
var a_group, b_group;
if ( typeof(a.grouping) === 'undefined' || typeof(a.grouping.groupPriority) === 'undefined' || a.grouping.groupPriority < 0){
if (a.isRowHeader){
a_group = -1000;
}
else if ( typeof(a.grouping) === 'undefined' || typeof(a.grouping.groupPriority) === 'undefined' || a.grouping.groupPriority < 0){
a_group = null;
} else {
a_group = a.grouping.groupPriority;
}

if ( typeof(b.grouping) === 'undefined' || typeof(b.grouping.groupPriority) === 'undefined' || b.grouping.groupPriority < 0){
if (b.isRowHeader){
b_group = -1000;
}
else if ( typeof(b.grouping) === 'undefined' || typeof(b.grouping.groupPriority) === 'undefined' || b.grouping.groupPriority < 0){
b_group = null;
} else {
b_group = b.grouping.groupPriority;
Expand Down
21 changes: 20 additions & 1 deletion src/features/grouping/test/grouping.spec.js
Expand Up @@ -7,18 +7,20 @@ describe('ui.grid.grouping uiGridGroupingService', function () {
var $rootScope;
var $scope;
var GridRow;
var $timeout;

beforeEach(module('ui.grid.grouping'));

beforeEach(inject(function (_uiGridGroupingService_,_gridClassFactory_, $templateCache, _uiGridGroupingConstants_,
_$rootScope_, _GridRow_, _uiGridTreeBaseService_) {
_$rootScope_, _GridRow_, _uiGridTreeBaseService_,_$timeout_) {
uiGridGroupingService = _uiGridGroupingService_;
uiGridGroupingConstants = _uiGridGroupingConstants_;
gridClassFactory = _gridClassFactory_;
$rootScope = _$rootScope_;
$scope = $rootScope.$new();
GridRow = _GridRow_;
uiGridTreeBaseService = _uiGridTreeBaseService_;
$timeout = _$timeout_;

$templateCache.put('ui-grid/uiGridCell', '<div/>');
$templateCache.put('ui-grid/editableCell', '<div editable_cell_directive></div>');
Expand Down Expand Up @@ -79,6 +81,23 @@ describe('ui.grid.grouping uiGridGroupingService', function () {
it( 'move some columns left, and some columns right', function() {
// TODO
});

iit( 'will not move header columns', function() {

$timeout(function () {
grid.addRowHeaderColumn({name:'aRowHeader'});
});
$timeout.flush();


grid.columns[2].renderContainer = 'left';
grid.columns[2].sort = { priority: 1};
grid.columns[2].grouping = { groupPriority: 1};
uiGridGroupingService.moveGroupColumns(grid,grid.columns,grid.rows);
expect(grid.columns[0].colDef.name).toBe('aRowHeader');


});
});


Expand Down

0 comments on commit acb7e7b

Please sign in to comment.