-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(saveState): add pinning to save state
The idea was to update saveState to include pinning. This turned out to be more involved than initial anticipated. I ended up having to update the pinning feature to include a public event and method so saveState could include pinning as an option. I updated documentation as I worked through it and even updated the tutorial to include pinning. This is in reference to an feature request I made recently #3123.
- Loading branch information
1 parent
949013c
commit b0d943a
Showing
6 changed files
with
318 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<!DOCTYPE html> | ||
<html class="no-js" ng-app="test"><!--<![endif]--> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"> | ||
<title></title> | ||
<meta content="width=device-width" name="viewport"> | ||
|
||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" /> | ||
<link href="/dist/release/ui-grid.css" rel="stylesheet"> | ||
|
||
<!--<script src="https://code.jquery.com/jquery-1.11.1.js"></script>--> | ||
<script src="/lib/test/angular/1.2.26/angular.js"></script> | ||
<script src="/dist/release/ui-grid.js"></script> | ||
|
||
<style> | ||
body { | ||
padding: 60px; | ||
min-height: 600px; | ||
} | ||
.grid { | ||
width: 500px; | ||
height: 400px; | ||
} | ||
</style> | ||
</head> | ||
<body ng-controller="Main"> | ||
|
||
<h2>Grid</h2> | ||
<div ui-grid="gridOptions" class="grid" ui-grid-save-state ui-grid-selection ui-grid-cellNav ui-grid-resize-columns ui-grid-move-columns ui-grid-pinning ></div> | ||
<button id="save" type="button" class="btn btn-success" ng-click="saveState()">Save</button> | ||
<button id="restore" type="button" class="btn btn-success" ng-click="restoreState()">Restore</button> | ||
|
||
<br> | ||
<br> | ||
|
||
<script> | ||
var app = angular.module('test', ['ui.grid', 'ui.grid.pinning', 'ui.grid.resizeColumns', 'ui.grid.saveState']); | ||
app.controller('Main', function($scope, $http) { | ||
$scope.gridOptions = {}; | ||
$scope.gridOptions.columnDefs = [ | ||
{ name:'id', width:50 }, | ||
{ name:'name', width:100, pinnedLeft:true }, | ||
{ name:'age', width:100, pinnedRight:true }, | ||
{ name:'address.street', width:150 }, | ||
{ name:'address.city', width:150 }, | ||
{ name:'address.state', width:50 }, | ||
{ name:'address.zip', width:50 }, | ||
{ name:'company', width:100 }, | ||
{ name:'email', width:100 }, | ||
{ name:'phone', width:200 }, | ||
{ name:'about', width:300 }, | ||
{ name:'friends[0].name', displayName:'1st friend', width:150 }, | ||
{ name:'friends[1].name', displayName:'2nd friend', width:150 }, | ||
{ name:'friends[2].name', displayName:'3rd friend', width:150 } | ||
]; | ||
$scope.gridOptions.enableFiltering = true; | ||
$scope.gridOptions.onRegisterApi = function(gridApi) { | ||
$scope.gridApi = gridApi; | ||
|
||
gridApi.pinning.on.columnPinned($scope, function(col, action) { | ||
console.log(col, action); | ||
}); | ||
}; | ||
$scope.state = {}; | ||
|
||
$scope.saveState = function() { | ||
$scope.state = $scope.gridApi.saveState.save(); | ||
}; | ||
|
||
$scope.restoreState = function() { | ||
$scope.gridApi.saveState.restore( $scope, $scope.state ); | ||
}; | ||
|
||
$http.get('https://rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json') | ||
.success(function(data) { | ||
$scope.gridOptions.data = data; | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.