Skip to content

Commit

Permalink
fix(resize-columns): Replace with
Browse files Browse the repository at this point in the history
Also, updated tutorial page to match angular style guide standards.
  • Loading branch information
Portugal, Marcelo authored and mportuga committed Jan 15, 2018
1 parent 2d40955 commit b77ddc3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 8 additions & 6 deletions misc/tutorial/204_column_resizing.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ $scope.gridOptions = {
<file name="app.js">
var app = angular.module('app', ['ngTouch', 'ui.grid', 'ui.grid.resizeColumns', 'ui.grid.moveColumns']);

app.controller('MainCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.gridOptions = {
app.controller('MainCtrl', function ($scope, $http) {
var vm = this;

vm.gridOptions = {
enableSorting: true,
columnDefs: [
{ field: 'name', minWidth: 200, width: 250, enableColumnResizing: false },
Expand All @@ -71,19 +73,19 @@ $scope.gridOptions = {

$http.get('/data/100.json')
.then(function(response) {
$scope.gridOptions.data = response.data;
vm.gridOptions.data = response.data;
});
}]);
});
</file>
<file name="index.html">
<div ng-controller="MainCtrl">
<div ng-controller="MainCtrl as $ctrl">
<strong>Drag</strong> a the column separator to resize; <strong>double-click</strong> to size according to rendered column contents.
<br>
<br>
The column will obey any <i>minWidth</i> or <i>maxWidth</i> constraints you give it.
<br>
<br>
<div ui-grid="gridOptions" class="grid" ui-grid-resize-columns ui-grid-move-columns></div>
<div ui-grid="$ctrl.gridOptions" class="grid" ui-grid-resize-columns ui-grid-move-columns></div>
</div>
</file>
<file name="main.css">
Expand Down
12 changes: 6 additions & 6 deletions src/features/resize-columns/js/ui-grid-column-resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/
var module = angular.module('ui.grid.resizeColumns', ['ui.grid']);

module.service('uiGridResizeColumnsService', ['gridUtil', '$q', '$timeout',
function (gridUtil, $q, $timeout) {
module.service('uiGridResizeColumnsService', ['gridUtil', '$q', '$rootScope',
function (gridUtil, $q, $rootScope) {

var service = {
defaultGridOptions: function(gridOptions){
Expand Down Expand Up @@ -103,7 +103,7 @@
},

fireColumnSizeChanged: function (grid, colDef, deltaChange) {
$timeout(function () {
$rootScope.$applyAsync(function () {
if ( grid.api.colResizable ){
grid.api.colResizable.raise.columnSizeChanged(colDef, deltaChange);
} else {
Expand Down Expand Up @@ -190,7 +190,7 @@
}]);

// Extend the uiGridHeaderCell directive
module.directive('uiGridHeaderCell', ['gridUtil', '$templateCache', '$compile', '$q', 'uiGridResizeColumnsService', 'uiGridConstants', '$timeout', function (gridUtil, $templateCache, $compile, $q, uiGridResizeColumnsService, uiGridConstants, $timeout) {
module.directive('uiGridHeaderCell', ['gridUtil', '$templateCache', '$compile', '$q', 'uiGridResizeColumnsService', 'uiGridConstants', function (gridUtil, $templateCache, $compile, $q, uiGridResizeColumnsService, uiGridConstants) {
return {
// Run after the original uiGridHeaderCell
priority: -10,
Expand Down Expand Up @@ -244,8 +244,8 @@

displayResizers();

var waitDisplay = function(){
$timeout(displayResizers);
var waitDisplay = function() {
$scope.$applyAsync(displayResizers);
};

var dataChangeDereg = grid.registerDataChangeCallback( waitDisplay, [uiGridConstants.dataChange.COLUMN] );
Expand Down

0 comments on commit b77ddc3

Please sign in to comment.