Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide/show ng-grid column externally?

I am using ng-grid where i want to hide/show columns on external button click.

I tried this, but its not working

$scope.gridOptions.$gridScope.columns[0].toggleVisible()
like image 808
Anoj Philip Avatar asked Sep 06 '13 10:09

Anoj Philip


1 Answers

Try using the ng-click directive

your html button could look like this

<input type="button" ng-click="toggleCol(0)" />

and your js like this

var app = angular.module('myCoolGridApp', ['ngGrid']);
app.controller('MyCtrl', function ($scope) {
    $scope.toggleCol= function(i) {
       $scope.gridOptions.$gridScope.columns[i].toggleVisible()
    }
}
like image 106
AardVark71 Avatar answered Sep 28 '22 08:09

AardVark71