how to hide/show ng-grid column externally?

2019-02-13 15:04发布

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()

1条回答
对你真心纯属浪费
2楼-- · 2019-02-13 15:24

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()
    }
}
查看更多
登录 后发表回答