Skip to content

Commit d799509

Browse files
Portugal, Marcelomportuga
authored andcommitted
chore(401_AllFeatures.ngdoc): Updating All Features tutorial
1 parent a794034 commit d799509

File tree

1 file changed

+47
-37
lines changed

1 file changed

+47
-37
lines changed

misc/tutorial/401_AllFeatures.ngdoc

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,55 @@ All features are enabled to get an idea of performance
1515

1616
app.controller('MainCtrl', ['$scope', '$http', '$timeout', '$interval', 'uiGridConstants', 'uiGridGroupingConstants',
1717
function ($scope, $http, $timeout, $interval, uiGridConstants, uiGridGroupingConstants) {
18-
19-
$scope.gridOptions = {};
20-
$scope.gridOptions.data = 'myData';
21-
$scope.gridOptions.enableCellEditOnFocus = true;
22-
$scope.gridOptions.enableColumnResizing = true;
23-
$scope.gridOptions.enableFiltering = true;
24-
$scope.gridOptions.enableGridMenu = true;
25-
$scope.gridOptions.showGridFooter = true;
26-
$scope.gridOptions.showColumnFooter = true;
27-
$scope.gridOptions.fastWatch = true;
28-
29-
$scope.gridOptions.rowIdentity = function(row) {
30-
return row.id;
18+
var gridApi;
19+
20+
$scope.gridOptions = {
21+
data: 'myData',
22+
enableCellEditOnFocus: true,
23+
enableColumnResizing: true,
24+
enableFiltering: true,
25+
enableGridMenu: true,
26+
showGridFooter: true,
27+
showColumnFooter: true,
28+
fastWatch: true,
29+
rowIdentity: getRowId,
30+
getRowIdentity: getRowId,
31+
importerDataAddCallback: function importerDataAddCallback( grid, newObjects ) {
32+
$scope.myData = $scope.data.concat( newObjects );
33+
},
34+
columnDefs: [
35+
{ name:'id', width:50 },
36+
{ name:'name', width:100 },
37+
{ name:'age', width:100, enableCellEdit: true, aggregationType: uiGridConstants.aggregationTypes.avg, treeAggregationType: uiGridGroupingConstants.aggregation.AVG },
38+
{ name:'address.street', width:150, enableCellEdit: true },
39+
{ name:'address.city', width:150, enableCellEdit: true },
40+
{ name:'address.state', width:50, enableCellEdit: true },
41+
{ name:'address.zip', width:50, enableCellEdit: true },
42+
{ name:'company', width:100, enableCellEdit: true },
43+
{ name:'email', width:100, enableCellEdit: true },
44+
{ name:'phone', width:200, enableCellEdit: true },
45+
{ name:'about', width:300, enableCellEdit: true },
46+
{ name:'friends[0].name', displayName:'1st friend', width:150, enableCellEdit: true },
47+
{ name:'friends[1].name', displayName:'2nd friend', width:150, enableCellEdit: true },
48+
{ name:'friends[2].name', displayName:'3rd friend', width:150, enableCellEdit: true },
49+
{ name:'agetemplate',field:'age', width:150, cellTemplate: '<div class="ui-grid-cell-contents"><span>Age 2:{{COL_FIELD}}</span></div>' },
50+
{ name:'Is Active',field:'isActive', width:150, type:'boolean' },
51+
{ name:'Join Date',field:'registered', cellFilter:'date', width:150, type:'date', enableFiltering: false },
52+
{ name:'Month Joined',field:'registered', cellFilter: 'date:"MMMM"', filterCellFiltered: true, sortCellFiltered: true, width:150, type:'date' }
53+
],
54+
onRegisterApi: function onRegisterApi(registeredApi) {
55+
gridApi = registeredApi;
56+
}
3157
};
32-
$scope.gridOptions.getRowIdentity = function(row) {
58+
59+
function getRowId(row) {
3360
return row.id;
34-
};
61+
}
3562

36-
$scope.gridOptions.columnDefs = [
37-
{ name:'id', width:50 },
38-
{ name:'name', width:100 },
39-
{ name:'age', width:100, enableCellEdit: true, aggregationType:uiGridConstants.aggregationTypes.avg, treeAggregationType: uiGridGroupingConstants.aggregation.AVG },
40-
{ name:'address.street', width:150, enableCellEdit: true },
41-
{ name:'address.city', width:150, enableCellEdit: true },
42-
{ name:'address.state', width:50, enableCellEdit: true },
43-
{ name:'address.zip', width:50, enableCellEdit: true },
44-
{ name:'company', width:100, enableCellEdit: true },
45-
{ name:'email', width:100, enableCellEdit: true },
46-
{ name:'phone', width:200, enableCellEdit: true },
47-
{ name:'about', width:300, enableCellEdit: true },
48-
{ name:'friends[0].name', displayName:'1st friend', width:150, enableCellEdit: true },
49-
{ name:'friends[1].name', displayName:'2nd friend', width:150, enableCellEdit: true },
50-
{ name:'friends[2].name', displayName:'3rd friend', width:150, enableCellEdit: true },
51-
{ name:'agetemplate',field:'age', width:150, cellTemplate: '<div class="ui-grid-cell-contents"><span>Age 2:{{COL_FIELD}}</span></div>' },
52-
{ name:'Is Active',field:'isActive', width:150, type:'boolean' },
53-
{ name:'Join Date',field:'registered', cellFilter:'date', width:150, type:'date', enableFiltering:false },
54-
{ name:'Month Joined',field:'registered', cellFilter: 'date:"MMMM"', filterCellFiltered:true, sortCellFiltered:true, width:150, type:'date' }
55-
];
63+
$scope.toggleFilterRow = function() {
64+
$scope.gridOptions.enableFiltering = !$scope.gridOptions.enableFiltering;
65+
gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN);
66+
};
5667

5768
$scope.callsPending = 0;
5869

@@ -90,13 +101,12 @@ All features are enabled to get an idea of performance
90101
$timeout.cancel(timeout);
91102
$interval.cancel(sec);
92103
});
93-
94104
};
95-
96105
}]);
97106
</file>
98107
<file name="index.html">
99108
<div ng-controller="MainCtrl">
109+
<button id="filterToggle" type="button" class="btn btn-success" ng-click="toggleFilterRow()">Toggle Filter</button>
100110
<button id="refreshButton" type="button" class="btn btn-success" ng-click="refreshData()">Refresh Data</button> <strong>Calls Pending:</strong> <span ng-bind="callsPending"></span>
101111
<br>
102112
<br>

0 commit comments

Comments
 (0)