Skip to content

Commit

Permalink
Merge pull request #47 from lakshmipg/pinnedColumnIssue
Browse files Browse the repository at this point in the history
error while dragging pinned column
  • Loading branch information
Umer Farooq authored Jun 10, 2016
2 parents 78adadf + 8db03b4 commit 0c0a7da
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
19 changes: 11 additions & 8 deletions src/features/move-columns/js/column-movable.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,17 @@
compile: function () {
return {
post: function ($scope, $elm, $attrs, uiGridCtrl) {
$scope.$watch('grid.options.enableColumnMoving', function (enableMoving) {
if (enableMoving) {
onDownEvents();
}
else {
offAllEvents();
}
});
function enableColumnMove(){
if ($scope.grid.options.enableColumnMoving && $scope.col.colDef.enableColumnMoving) {
onDownEvents();
}
else {
offAllEvents();
}
}
$scope.$watch('grid.options.enableColumnMoving', enableColumnMove);

$scope.$watch('col.colDef.enableColumnMoving', enableColumnMove);

/*
* Our general approach to column move is that we listen to a touchstart or mousedown
Expand Down
26 changes: 23 additions & 3 deletions src/features/move-columns/test/column-movable.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ describe('ui.grid.moveColumns', function () {
timeout = $timeout;
gridUtil = _gridUtil_;
document = $document;
uiGridConstants = _uiGridConstants_;

uiGridConstants = _uiGridConstants_;
scope.gridOptions = {};
scope.gridOptions.data = data;
scope.gridOptions.columnDefs = [
Expand Down Expand Up @@ -194,12 +193,33 @@ describe('ui.grid.moveColumns', function () {

it('expect column movement to happen if enableColumnMoving is changed to true', function() {
scope.grid.options.enableColumnMoving = false;
scope.grid.options.enableColumnMoving = true;
scope.grid.options.enableColumnMoving = true;
scope.gridApi.colMovable.moveColumn(0, 1);
expect(scope.grid.columns[0].name).toBe('gender');
expect(scope.grid.columns[1].name).toBe('name');
expect(scope.grid.columns[2].name).toBe('age');
expect(scope.grid.columns[3].name).toBe('company');
expect(scope.grid.columns[4].name).toBe('phone');
});

it('expect column movement no to happen if column Defination enableColumnMoving is changed to false', function(){
scope.grid.options.enableColumnMoving = true;
scope.grid.columns[2].colDef.enableColumnMoving = false;
scope.gridApi.colMovable.moveColumn(2, 0);
expect(scope.grid.columns[0].name).toBe('name');
expect(scope.grid.columns[2].name).toBe('age');
});

it('expect column movement not to happen for column defination enableColumnMoving is false by default', function(){
scope.gridApi.colMovable.moveColumn(2, 0);
expect(scope.grid.columns[0].name).toBe('name');
expect(scope.grid.columns[3].name).toBe('company');
});

it('expect column movement to be happen for changing the column defination enableColumnMoving property to true which is false by default', function(){
scope.grid.columns[3].colDef.enableColumnMoving = true;
scope.gridApi.colMovable.moveColumn(2, 0);
expect(scope.grid.columns[0].name).toBe('company');
expect(scope.grid.columns[3].name).toBe('age');
});
});

0 comments on commit 0c0a7da

Please sign in to comment.