我在我的页面中使用了角度UI-Grid但是当我使用组功能时它不能正常工作。
获取错误的步骤: 1)保存初始状态; 2)组合任何colunm(例如年龄) 3)恢复网格状态;
第三步之后,会产生几个错误:aggregation.col.treeAggregationFn不是函数。
如果我删除属性“showColumnFooter”,则网格正常工作。
var app = angular.module('app', ['ngAnimate', 'ngTouch', 'ui.grid', 'ui.grid.saveState', 'ui.grid.selection', 'ui.grid.cellNav', 'ui.grid.resizeColumns', 'ui.grid.moveColumns', 'ui.grid.pinning', 'ui.grid.grouping' ]);
app.controller('MainCtrl', ['$scope', '$http', '$interval', function ($scope, $http, $interval) {
$scope.gridOptions = {
saveFocus: false,
saveScroll: true,
showColumnFooter: true,
saveGroupingExpandedStates: true,
enableFiltering: true,
columnDefs: [
{ name: 'name' },
{ name: 'gender' },
{ name: 'company' }
],
onRegisterApi: function(gridApi){
$scope.gridApi = gridApi;
}
};
$scope.state = {};
$scope.saveState = function() {
$scope.state = $scope.gridApi.saveState.save();
};
$scope.restoreState = function() {
$scope.gridApi.saveState.restore( $scope, $scope.state );
};
$http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/100.json')
.success(function(data) {
$scope.gridOptions.data = data;
});
}]);
.grid {
width: 500px;
height: 400px;
}
<!doctype html>
<html ng-app="app">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-touch.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-animate.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/csv.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script>
<script src="http://ui-grid.info/release/ui-grid.js"></script>
<link rel="stylesheet" href="http://ui-grid.info/release/ui-grid.css" type="text/css">
<link rel="stylesheet" href="main.css" type="text/css">
</head>
<body>
<div ng-controller="MainCtrl">
<div id="gridSaveState" ui-grid="gridOptions" ui-grid-save-state ui-grid-selection ui-grid-cellNav ui-grid-resize-columns ui-grid-move-columns ui-grid-pinning ui-grid-grouping class="grid"></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>
</div>
<script src="app.js"></script>
</body>
</html>