howto disable selection in ng-grid



Is it possible to “disable” or lock the selection of a ng-grid using the inbuilt functionality? I want the user to be able to select a row, click a button and then the grid will stay locked until the user presses another button.


Yes, you can return false from beforeSelectionChange to disable changing the selected rows on the grid.

$scope.option = {
    enableRowSelection: true,
$scope.gridOptions = {
    data: 'myData',
    beforeSelectionChange: function() {
      return $scope.option.enableRowSelection;
    //, ...


<button ng-click="option.enableRowSelection=false">Freeze Selection</button>
<button ng-click="option.enableRowSelection=true">Unfreeze Selection</button>
<div class="gridStyle" ng-grid="gridOptions"></div>

Example Code:

See also:

Answered By – user508994

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More