Skip to content

Commit

Permalink
additional functionality for #258 & #91
Browse files Browse the repository at this point in the history
added grid option "groupsCollapedByDefault:  true" and it is true by
default
  • Loading branch information
orneryd committed Apr 2, 2013
1 parent 2c65a87 commit d33b642
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 34 deletions.
19 changes: 11 additions & 8 deletions build/ng-grid.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-grid JavaScript Library
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
* Compiled At: 04/02/2013 00:18
* Compiled At: 04/02/2013 00:44
***********************************************/
(function(window, $) {
'use strict';
Expand Down Expand Up @@ -586,7 +586,7 @@ ngGridServices.factory('$utilityService', ['$parse', function ($parse) {
});
return utils;
}]);
var ngAggregate = function (aggEntity, rowFactory, rowHeight) {
var ngAggregate = function (aggEntity, rowFactory, rowHeight, groupInitState) {
var self = this;
self.rowIndex = 0;
self.offsetTop = self.rowIndex * rowHeight;
Expand All @@ -598,7 +598,7 @@ var ngAggregate = function (aggEntity, rowFactory, rowHeight) {
self.children = aggEntity.children;
self.aggChildren = aggEntity.aggChildren;
self.aggIndex = aggEntity.aggIndex;
self.collapsed = true;
self.collapsed = groupInitState;
self.isAggRow = true;
self.offsetLeft = aggEntity.gDepth * 25;
self.aggLabelFilter = aggEntity.aggLabelFilter;
Expand Down Expand Up @@ -655,7 +655,7 @@ var ngAggregate = function (aggEntity, rowFactory, rowHeight) {
}
};
self.copy = function () {
var ret = new ngAggregate(self.entity, rowFactory, rowHeight);
var ret = new ngAggregate(self.entity, rowFactory, rowHeight, groupInitState);
ret.orig = self;
return ret;
};
Expand Down Expand Up @@ -1278,7 +1278,10 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,

//Initial fields to group data by. Array of field names, not displayName.
groups: [],


// set the initial state of aggreagate grouping. "true" means they will be collapsed when grouping changes, "false" means they will be expanded by default.
groupsCollapedByDefault: true,

//The height of the header row in pixels.
headerRowHeight: 30,

Expand Down Expand Up @@ -1916,7 +1919,7 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
return;
}
//first sort the column
if (!col.sortDirection) col.sort({ shiftKey: false });
if (!col.sortDirection) col.sort({ shiftKey: $scope.configGroups.length > 0 ? true : false });

var indx = $scope.configGroups.indexOf(col);
if (indx == -1) {
Expand Down Expand Up @@ -2114,7 +2117,7 @@ var ngRowFactory = function (grid, $scope, domUtilityService, $templateCache, $u
var agg = self.aggCache[aggEntity.aggIndex]; // first check to see if we've already built it
if (!agg) {
// build the row
agg = new ngAggregate(aggEntity, self, self.rowConfig.rowHeight);
agg = new ngAggregate(aggEntity, self, self.rowConfig.rowHeight, grid.config.groupsCollapedByDefault);
self.aggCache[aggEntity.aggIndex] = agg;
}
agg.rowIndex = rowIndex;
Expand Down Expand Up @@ -2256,7 +2259,7 @@ var ngRowFactory = function (grid, $scope, domUtilityService, $templateCache, $u
for (var x = 0; x < rows.length; x++){
var model = rows[x].entity;
if (!model) return;
rows[x][NG_HIDDEN] = true;
rows[x][NG_HIDDEN] = grid.config.groupsCollapedByDefault;
var ptr = self.groupedData;
for (var y = 0; y < groups.length; y++) {
var group = groups[y];
Expand Down
15 changes: 8 additions & 7 deletions build/ng-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-grid JavaScript Library
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
* Compiled At: 04/02/2013 00:18
* Compiled At: 04/02/2013 00:44
***********************************************/
(function(window, $) {
'use strict';
Expand Down Expand Up @@ -539,7 +539,7 @@ ngGridServices.factory('$utilityService', ['$parse', function ($parse) {
});
return utils;
}]);
var ngAggregate = function (aggEntity, rowFactory, rowHeight) {
var ngAggregate = function (aggEntity, rowFactory, rowHeight, groupInitState) {
var self = this;
self.rowIndex = 0;
self.offsetTop = self.rowIndex * rowHeight;
Expand All @@ -551,7 +551,7 @@ var ngAggregate = function (aggEntity, rowFactory, rowHeight) {
self.children = aggEntity.children;
self.aggChildren = aggEntity.aggChildren;
self.aggIndex = aggEntity.aggIndex;
self.collapsed = true;
self.collapsed = groupInitState;
self.isAggRow = true;
self.offsetLeft = aggEntity.gDepth * 25;
self.aggLabelFilter = aggEntity.aggLabelFilter;
Expand Down Expand Up @@ -608,7 +608,7 @@ var ngAggregate = function (aggEntity, rowFactory, rowHeight) {
}
};
self.copy = function () {
var ret = new ngAggregate(self.entity, rowFactory, rowHeight);
var ret = new ngAggregate(self.entity, rowFactory, rowHeight, groupInitState);
ret.orig = self;
return ret;
};
Expand Down Expand Up @@ -1126,6 +1126,7 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
footerRowHeight: 55,
footerTemplate: undefined,
groups: [],
groupsCollapedByDefault: true,
headerRowHeight: 30,
headerRowTemplate: undefined,
jqueryUIDraggable: false,
Expand Down Expand Up @@ -1669,7 +1670,7 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
if (self.data.length < 1 || !col.groupable || !col.field) {
return;
}
if (!col.sortDirection) col.sort({ shiftKey: false });
if (!col.sortDirection) col.sort({ shiftKey: $scope.configGroups.length > 0 ? true : false });

var indx = $scope.configGroups.indexOf(col);
if (indx == -1) {
Expand Down Expand Up @@ -1856,7 +1857,7 @@ var ngRowFactory = function (grid, $scope, domUtilityService, $templateCache, $u
self.buildAggregateRow = function(aggEntity, rowIndex) {
var agg = self.aggCache[aggEntity.aggIndex];
if (!agg) {
agg = new ngAggregate(aggEntity, self, self.rowConfig.rowHeight);
agg = new ngAggregate(aggEntity, self, self.rowConfig.rowHeight, grid.config.groupsCollapedByDefault);
self.aggCache[aggEntity.aggIndex] = agg;
}
agg.rowIndex = rowIndex;
Expand Down Expand Up @@ -1984,7 +1985,7 @@ var ngRowFactory = function (grid, $scope, domUtilityService, $templateCache, $u
for (var x = 0; x < rows.length; x++){
var model = rows[x].entity;
if (!model) return;
rows[x][NG_HIDDEN] = true;
rows[x][NG_HIDDEN] = grid.config.groupsCollapedByDefault;
var ptr = self.groupedData;
for (var y = 0; y < groups.length; y++) {
var group = groups[y];
Expand Down
4 changes: 2 additions & 2 deletions build/ng-grid.min.js

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions ng-grid-2.0.3.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ng-grid JavaScript Library
* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
* Compiled At: 04/02/2013 00:18
* Compiled At: 04/02/2013 00:44
***********************************************/
(function(window, $) {
'use strict';
Expand Down Expand Up @@ -586,7 +586,7 @@ ngGridServices.factory('$utilityService', ['$parse', function ($parse) {
});
return utils;
}]);
var ngAggregate = function (aggEntity, rowFactory, rowHeight) {
var ngAggregate = function (aggEntity, rowFactory, rowHeight, groupInitState) {
var self = this;
self.rowIndex = 0;
self.offsetTop = self.rowIndex * rowHeight;
Expand All @@ -598,7 +598,7 @@ var ngAggregate = function (aggEntity, rowFactory, rowHeight) {
self.children = aggEntity.children;
self.aggChildren = aggEntity.aggChildren;
self.aggIndex = aggEntity.aggIndex;
self.collapsed = true;
self.collapsed = groupInitState;
self.isAggRow = true;
self.offsetLeft = aggEntity.gDepth * 25;
self.aggLabelFilter = aggEntity.aggLabelFilter;
Expand Down Expand Up @@ -655,7 +655,7 @@ var ngAggregate = function (aggEntity, rowFactory, rowHeight) {
}
};
self.copy = function () {
var ret = new ngAggregate(self.entity, rowFactory, rowHeight);
var ret = new ngAggregate(self.entity, rowFactory, rowHeight, groupInitState);
ret.orig = self;
return ret;
};
Expand Down Expand Up @@ -1278,7 +1278,10 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,

//Initial fields to group data by. Array of field names, not displayName.
groups: [],


// set the initial state of aggreagate grouping. "true" means they will be collapsed when grouping changes, "false" means they will be expanded by default.
groupsCollapedByDefault: true,

//The height of the header row in pixels.
headerRowHeight: 30,

Expand Down Expand Up @@ -1916,7 +1919,7 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
return;
}
//first sort the column
if (!col.sortDirection) col.sort({ shiftKey: false });
if (!col.sortDirection) col.sort({ shiftKey: $scope.configGroups.length > 0 ? true : false });

var indx = $scope.configGroups.indexOf(col);
if (indx == -1) {
Expand Down Expand Up @@ -2114,7 +2117,7 @@ var ngRowFactory = function (grid, $scope, domUtilityService, $templateCache, $u
var agg = self.aggCache[aggEntity.aggIndex]; // first check to see if we've already built it
if (!agg) {
// build the row
agg = new ngAggregate(aggEntity, self, self.rowConfig.rowHeight);
agg = new ngAggregate(aggEntity, self, self.rowConfig.rowHeight, grid.config.groupsCollapedByDefault);
self.aggCache[aggEntity.aggIndex] = agg;
}
agg.rowIndex = rowIndex;
Expand Down Expand Up @@ -2256,7 +2259,7 @@ var ngRowFactory = function (grid, $scope, domUtilityService, $templateCache, $u
for (var x = 0; x < rows.length; x++){
var model = rows[x].entity;
if (!model) return;
rows[x][NG_HIDDEN] = true;
rows[x][NG_HIDDEN] = grid.config.groupsCollapedByDefault;
var ptr = self.groupedData;
for (var y = 0; y < groups.length; y++) {
var group = groups[y];
Expand Down
4 changes: 2 additions & 2 deletions ng-grid-2.0.3.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/classes/aggregate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var ngAggregate = function (aggEntity, rowFactory, rowHeight) {
var ngAggregate = function (aggEntity, rowFactory, rowHeight, groupInitState) {
var self = this;
self.rowIndex = 0;
self.offsetTop = self.rowIndex * rowHeight;
Expand All @@ -10,7 +10,7 @@ var ngAggregate = function (aggEntity, rowFactory, rowHeight) {
self.children = aggEntity.children;
self.aggChildren = aggEntity.aggChildren;
self.aggIndex = aggEntity.aggIndex;
self.collapsed = true;
self.collapsed = groupInitState;
self.isAggRow = true;
self.offsetLeft = aggEntity.gDepth * 25;
self.aggLabelFilter = aggEntity.aggLabelFilter;
Expand Down Expand Up @@ -67,7 +67,7 @@ var ngAggregate = function (aggEntity, rowFactory, rowHeight) {
}
};
self.copy = function () {
var ret = new ngAggregate(self.entity, rowFactory, rowHeight);
var ret = new ngAggregate(self.entity, rowFactory, rowHeight, groupInitState);
ret.orig = self;
return ret;
};
Expand Down
7 changes: 5 additions & 2 deletions src/classes/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,

//Initial fields to group data by. Array of field names, not displayName.
groups: [],


// set the initial state of aggreagate grouping. "true" means they will be collapsed when grouping changes, "false" means they will be expanded by default.
groupsCollapedByDefault: true,

//The height of the header row in pixels.
headerRowHeight: 30,

Expand Down Expand Up @@ -725,7 +728,7 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
return;
}
//first sort the column
if (!col.sortDirection) col.sort({ shiftKey: false });
if (!col.sortDirection) col.sort({ shiftKey: $scope.configGroups.length > 0 ? true : false });

var indx = $scope.configGroups.indexOf(col);
if (indx == -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/classes/rowFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
var agg = self.aggCache[aggEntity.aggIndex]; // first check to see if we've already built it
if (!agg) {
// build the row
agg = new ngAggregate(aggEntity, self, self.rowConfig.rowHeight);
agg = new ngAggregate(aggEntity, self, self.rowConfig.rowHeight, grid.config.groupsCollapedByDefault);
self.aggCache[aggEntity.aggIndex] = agg;
}
agg.rowIndex = rowIndex;
Expand Down Expand Up @@ -178,7 +178,7 @@
for (var x = 0; x < rows.length; x++){
var model = rows[x].entity;
if (!model) return;
rows[x][NG_HIDDEN] = true;
rows[x][NG_HIDDEN] = grid.config.groupsCollapedByDefault;
var ptr = self.groupedData;
for (var y = 0; y < groups.length; y++) {
var group = groups[y];
Expand Down
1 change: 1 addition & 0 deletions workbench/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ function userController($scope) {
multiSelect: true,
columnDefs: 'myDefs2',
enablePinning: true,
groupsCollapedByDefault: false
};
$scope.changeData = function () {
$scope.myData2.pop();
Expand Down

0 comments on commit d33b642

Please sign in to comment.