Skip to content

Commit

Permalink
fix(expandable): Stop adding Expandable column and behavior if featur…
Browse files Browse the repository at this point in the history
…e is disabled
  • Loading branch information
swalters committed Feb 16, 2016
1 parent 2762eda commit 0bb1208
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/features/expandable/js/expandable.js
Expand Up @@ -324,7 +324,13 @@
compile: function () {
return {
pre: function ($scope, $elm, $attrs, uiGridCtrl) {
if ( uiGridCtrl.grid.options.enableExpandableRowHeader !== false ) {
uiGridExpandableService.initializeGrid(uiGridCtrl.grid);

if (!uiGridCtrl.grid.options.enableExpandable) {
return;
}

if (uiGridCtrl.grid.options.enableExpandableRowHeader !== false ) {
var expandableRowHeaderColDef = {
name: 'expandableButtons',
displayName: '',
Expand All @@ -337,7 +343,7 @@
expandableRowHeaderColDef.headerCellTemplate = $templateCache.get('ui-grid/expandableTopRowHeader');
uiGridCtrl.grid.addRowHeaderColumn(expandableRowHeaderColDef);
}
uiGridExpandableService.initializeGrid(uiGridCtrl.grid);

},
post: function ($scope, $elm, $attrs, uiGridCtrl) {
}
Expand Down Expand Up @@ -454,6 +460,10 @@
return {
pre: function ($scope, $elm, $attrs, controllers) {

if (!$scope.grid.options.enableExpandable) {
return;
}

$scope.expandableRow = {};

$scope.expandableRow.shouldRenderExpand = function () {
Expand Down Expand Up @@ -512,6 +522,11 @@
priority: -200,
scope: false,
compile: function ($elm, $attrs) {

//todo: this adds ng-if watchers to each row even if the grid is not using expandable directive
// or options.enableExpandable == false
// The alternative is to compile the template and append to each row in a uiGridRow directive

var rowRepeatDiv = angular.element($elm.children().children()[0]);
var expandedRowFillerElement = $templateCache.get('ui-grid/expandableScrollFiller');
var expandedRowElement = $templateCache.get('ui-grid/expandableRow');
Expand Down

0 comments on commit 0bb1208

Please sign in to comment.