-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix(5007): Reduced the amount of digest cycles initiated by the grid. #6072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,44 +15,52 @@ All features are enabled to get an idea of performance | |
|
||
app.controller('MainCtrl', ['$scope', '$http', '$timeout', '$interval', 'uiGridConstants', 'uiGridGroupingConstants', | ||
function ($scope, $http, $timeout, $interval, uiGridConstants, uiGridGroupingConstants) { | ||
|
||
$scope.gridOptions = {}; | ||
$scope.gridOptions.data = 'myData'; | ||
$scope.gridOptions.enableCellEditOnFocus = true; | ||
$scope.gridOptions.enableColumnResizing = true; | ||
$scope.gridOptions.enableFiltering = true; | ||
$scope.gridOptions.enableGridMenu = true; | ||
$scope.gridOptions.showGridFooter = true; | ||
$scope.gridOptions.showColumnFooter = true; | ||
$scope.gridOptions.fastWatch = true; | ||
|
||
$scope.gridOptions.rowIdentity = function(row) { | ||
return row.id; | ||
var gridApi; | ||
|
||
$scope.gridOptions = { | ||
data: 'myData', | ||
enableCellEditOnFocus: true, | ||
enableColumnResizing: true, | ||
enableFiltering: true, | ||
enableGridMenu: true, | ||
showGridFooter: true, | ||
showColumnFooter: true, | ||
fastWatch: true, | ||
rowIdentity: getRowId, | ||
getRowIdentity: getRowId, | ||
columnDefs: [ | ||
{ name:'id', width:50 }, | ||
{ name:'name', width:100 }, | ||
{ name:'age', width:100, enableCellEdit: true, aggregationType:uiGridConstants.aggregationTypes.avg, treeAggregationType: uiGridGroupingConstants.aggregation.AVG }, | ||
{ name:'address.street', width:150, enableCellEdit: true }, | ||
{ name:'address.city', width:150, enableCellEdit: true }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This moved to line 31 |
||
{ name:'address.state', width:50, enableCellEdit: true }, | ||
{ name:'address.zip', width:50, enableCellEdit: true }, | ||
{ name:'company', width:100, enableCellEdit: true }, | ||
{ name:'email', width:100, enableCellEdit: true }, | ||
{ name:'phone', width:200, enableCellEdit: true }, | ||
{ name:'about', width:300, enableCellEdit: true }, | ||
{ name:'friends[0].name', displayName:'1st friend', width:150, enableCellEdit: true }, | ||
{ name:'friends[1].name', displayName:'2nd friend', width:150, enableCellEdit: true }, | ||
{ name:'friends[2].name', displayName:'3rd friend', width:150, enableCellEdit: true }, | ||
{ name:'agetemplate',field:'age', width:150, cellTemplate: '<div class="ui-grid-cell-contents"><span>Age 2:{{COL_FIELD}}</span></div>' }, | ||
{ name:'Is Active',field:'isActive', width:150, type:'boolean' }, | ||
{ name:'Join Date',field:'registered', cellFilter:'date', width:150, type:'date', enableFiltering:false }, | ||
{ name:'Month Joined',field:'registered', cellFilter: 'date:"MMMM"', filterCellFiltered:true, sortCellFiltered:true, width:150, type:'date' } | ||
], | ||
onRegisterApi: function onRegisterApi(registeredApi) { | ||
gridApi = registeredApi; | ||
} | ||
}; | ||
$scope.gridOptions.getRowIdentity = function(row) { | ||
|
||
function getRowId(row) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function was repeated for getRowIndentity and rowIdentity, so I combined them. |
||
return row.id; | ||
}; | ||
} | ||
|
||
$scope.gridOptions.columnDefs = [ | ||
{ name:'id', width:50 }, | ||
{ name:'name', width:100 }, | ||
{ name:'age', width:100, enableCellEdit: true, aggregationType:uiGridConstants.aggregationTypes.avg, treeAggregationType: uiGridGroupingConstants.aggregation.AVG }, | ||
{ name:'address.street', width:150, enableCellEdit: true }, | ||
{ name:'address.city', width:150, enableCellEdit: true }, | ||
{ name:'address.state', width:50, enableCellEdit: true }, | ||
{ name:'address.zip', width:50, enableCellEdit: true }, | ||
{ name:'company', width:100, enableCellEdit: true }, | ||
{ name:'email', width:100, enableCellEdit: true }, | ||
{ name:'phone', width:200, enableCellEdit: true }, | ||
{ name:'about', width:300, enableCellEdit: true }, | ||
{ name:'friends[0].name', displayName:'1st friend', width:150, enableCellEdit: true }, | ||
{ name:'friends[1].name', displayName:'2nd friend', width:150, enableCellEdit: true }, | ||
{ name:'friends[2].name', displayName:'3rd friend', width:150, enableCellEdit: true }, | ||
{ name:'agetemplate',field:'age', width:150, cellTemplate: '<div class="ui-grid-cell-contents"><span>Age 2:{{COL_FIELD}}</span></div>' }, | ||
{ name:'Is Active',field:'isActive', width:150, type:'boolean' }, | ||
{ name:'Join Date',field:'registered', cellFilter:'date', width:150, type:'date', enableFiltering:false }, | ||
{ name:'Month Joined',field:'registered', cellFilter: 'date:"MMMM"', filterCellFiltered:true, sortCellFiltered:true, width:150, type:'date' } | ||
]; | ||
$scope.toggleFilterRow = function() { | ||
$scope.gridOptions.enableFiltering = !$scope.gridOptions.enableFiltering; | ||
gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN); | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is this used? Is it a new button designed into the grid? Why do you need to notifyDataChange? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is a new button. And the grid will not update unless the event is fired. |
||
|
||
$scope.callsPending = 0; | ||
|
||
|
@@ -90,13 +98,12 @@ All features are enabled to get an idea of performance | |
$timeout.cancel(timeout); | ||
$interval.cancel(sec); | ||
}); | ||
|
||
}; | ||
|
||
}]); | ||
</file> | ||
<file name="index.html"> | ||
<div ng-controller="MainCtrl"> | ||
<button id="filterToggle" type="button" class="btn btn-success" ng-click="toggleFilterRow()">Toggle Filter</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find myself needing to test this a lot and I frequently see question about how to implement something like this, so I added it to this demo. |
||
<button id="refreshButton" type="button" class="btn btn-success" ng-click="refreshData()">Refresh Data</button> <strong>Calls Pending:</strong> <span ng-bind="callsPending"></span> | ||
<br> | ||
<br> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -664,7 +664,7 @@ | |
allowCellFocus: true | ||
}; | ||
|
||
uiGridCtrl.grid.addRowHeaderColumn(selectionRowHeaderDef, 0); | ||
uiGridCtrl.grid.addRowHeaderColumn(selectionRowHeaderDef, 0, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a new attribute to prevent build columns from being triggered multiple times in a row. ColumnDefs is now responsible for building the columns. See line 763 of Grid.js |
||
} | ||
|
||
var processorSet = false; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -715,7 +715,7 @@ | |
}; | ||
|
||
rowHeaderColumnDef.visible = grid.options.treeRowHeaderAlwaysVisible; | ||
grid.addRowHeaderColumn( rowHeaderColumnDef, -100 ); | ||
grid.addRowHeaderColumn(rowHeaderColumnDef, -100, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a new attribute to prevent build columns from being triggered multiple times in a row. ColumnDefs is now responsible for building the columns. See line 763 of Grid.js |
||
}, | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to combine the multiple calls to $scope.gridOptions.[something] into one object definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea