Skip to content

Commit 0bb1208

Browse files
committed
fix(expandable): Stop adding Expandable column and behavior if feature is disabled
1 parent 2762eda commit 0bb1208

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/features/expandable/js/expandable.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,13 @@
324324
compile: function () {
325325
return {
326326
pre: function ($scope, $elm, $attrs, uiGridCtrl) {
327-
if ( uiGridCtrl.grid.options.enableExpandableRowHeader !== false ) {
327+
uiGridExpandableService.initializeGrid(uiGridCtrl.grid);
328+
329+
if (!uiGridCtrl.grid.options.enableExpandable) {
330+
return;
331+
}
332+
333+
if (uiGridCtrl.grid.options.enableExpandableRowHeader !== false ) {
328334
var expandableRowHeaderColDef = {
329335
name: 'expandableButtons',
330336
displayName: '',
@@ -337,7 +343,7 @@
337343
expandableRowHeaderColDef.headerCellTemplate = $templateCache.get('ui-grid/expandableTopRowHeader');
338344
uiGridCtrl.grid.addRowHeaderColumn(expandableRowHeaderColDef);
339345
}
340-
uiGridExpandableService.initializeGrid(uiGridCtrl.grid);
346+
341347
},
342348
post: function ($scope, $elm, $attrs, uiGridCtrl) {
343349
}
@@ -454,6 +460,10 @@
454460
return {
455461
pre: function ($scope, $elm, $attrs, controllers) {
456462

463+
if (!$scope.grid.options.enableExpandable) {
464+
return;
465+
}
466+
457467
$scope.expandableRow = {};
458468

459469
$scope.expandableRow.shouldRenderExpand = function () {
@@ -512,6 +522,11 @@
512522
priority: -200,
513523
scope: false,
514524
compile: function ($elm, $attrs) {
525+
526+
//todo: this adds ng-if watchers to each row even if the grid is not using expandable directive
527+
// or options.enableExpandable == false
528+
// The alternative is to compile the template and append to each row in a uiGridRow directive
529+
515530
var rowRepeatDiv = angular.element($elm.children().children()[0]);
516531
var expandedRowFillerElement = $templateCache.get('ui-grid/expandableScrollFiller');
517532
var expandedRowElement = $templateCache.get('ui-grid/expandableRow');

0 commit comments

Comments
 (0)