Using ui-grid constants to disable scrollbars

nabinca picture nabinca · Nov 14, 2014 · Viewed 37.8k times · Source

With the latest version of ui-grid (v3.0.0-rc.16) it is possible to turn the horizontal and vertical scrollbar off seperately. I got this working by exchanging

$scope.gridOptions.enableScrollbars = false;

with

$scope.gridOptions.enableHorizontalScrollbar = 0;
$scope.gridOptions.enableVerticalScrollbar = 0;

In the sources of ui-grid there are three Constants defined for the scrollbars:

scrollbars: {
  NEVER: 0,
  ALWAYS: 1,
  WHEN_NEEDED: 2
}

Facing the fact that ui-grid is still unstable and changed very often, i would feel more comfortable using those constants instead of the specific values. But how can i access them ?

Plunker: http://plnkr.co/edit/h0ewAZK616rKCH3T62te

Answer

nabinca picture nabinca · Nov 16, 2014

Got my answer on github:

All I needed to do was to pass uiGridConstants to my controller like this:

angular.module('myApp').controller('myCtrl',function($scope,uiGridConstants) {
    ...

    $scope.gridOptions.enableHorizontalScrollbar = uiGridConstants.scrollbars.NEVER;

    ...
})