Skip to content

Commit d68dcc6

Browse files
committed
Merge pull request #3607 from PaulL1/treebase
Treebase
2 parents 90a51cc + 6cd5f8d commit d68dcc6

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

misc/tutorial/208_save_state.ngdoc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,18 @@ to something different, and use the restore button to set the grid back the way
4949
saveFocus: false,
5050
saveScroll: true,
5151
saveGroupingExpandedStates: true,
52+
enableFiltering: true,
53+
columnDefs: [
54+
{ name: 'name' },
55+
{ name: 'gender' },
56+
{ name: 'company' }
57+
],
5258
onRegisterApi: function(gridApi){
5359
$scope.gridApi = gridApi;
5460
}
5561
};
56-
$scope.gridOptions.enableFiltering = true;
5762
$scope.state = {};
58-
63+
5964
$scope.saveState = function() {
6065
$scope.state = $scope.gridApi.saveState.save();
6166
};

misc/tutorial/317_custom_templates.ngdoc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ In this example we create a grid almost the same as the most basic one, but with
1515
with a cellTemplate that totals all the items above it in the grid. This template continues to work when the data is
1616
filtered or sorted.
1717

18+
The custom row template merges all the cells together when the entity.merge value is true.
19+
1820
You can use [grid.appScope](/docs/#/tutorial/305_appScope) in your row template to access
1921
elements in your controller's scope. More details are on
2022
the [scopes](/docs/#/tutorial/305_appScope) tutorial.
@@ -40,7 +42,8 @@ In the cellTemplate you have access to `grid`, `row` and `column`, which allows
4042
$interval.cancel(sec);
4143
$scope.wait = '';
4244
return '<div ng-class="{ \'my-css-class\': grid.appScope.rowFormatter( row ) }">' +
43-
' <div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name" class="ui-grid-cell" ng-class="{ \'ui-grid-row-header-cell\': col.isRowHeader }" ui-grid-cell></div>' +
45+
' <div ng-if="row.entity.merge">{{row.entity.title}}</div>' +
46+
' <div ng-if="!row.entity.merge" ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name" class="ui-grid-cell" ng-class="{ \'ui-grid-row-header-cell\': col.isRowHeader }" ui-grid-cell></div>' +
4447
'</div>';
4548
}, 6000);
4649
}
@@ -57,6 +60,10 @@ In the cellTemplate you have access to `grid`, `row` and `column`, which allows
5760
data.forEach( function(row, index) {
5861
row.widgets = index % 10;
5962
});
63+
data[1].merge = true;
64+
data[1].title = "A merged row";
65+
data[4].merge = true;
66+
data[4].title = "Another merged row";
6067
$scope.data = data;
6168
});
6269

src/features/saveState/js/saveState.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,16 @@
357357
}
358358

359359
if ( grid.options.saveFilter ){
360-
savedColumn.filters = angular.copy ( column.filters );
360+
savedColumn.filters = [];
361+
column.filters.forEach( function( filter ){
362+
var copiedFilter = {};
363+
angular.forEach( filter, function( value, key) {
364+
if ( key !== 'condition' && key !== '$$hashKey' && key !== 'placeholder'){
365+
copiedFilter[key] = value;
366+
}
367+
});
368+
savedColumn.filters.push(copiedFilter);
369+
});
361370
}
362371

363372
if ( !!grid.api.pinning && grid.options.savePinning ){
@@ -545,7 +554,12 @@
545554

546555
if ( grid.options.saveFilter &&
547556
!angular.equals(currentCol.filters, columnState.filters ) ){
548-
currentCol.filters = angular.copy( columnState.filters );
557+
columnState.filters.forEach( function( filter, index ){
558+
angular.extend( currentCol.filters[index], filter );
559+
if ( typeof(filter.term) === 'undefined' || filter.term === null ){
560+
delete currentCol.filters[index].term;
561+
}
562+
});
549563
grid.api.core.raise.filterChanged();
550564
}
551565

0 commit comments

Comments
 (0)