how to hide/show ng-grid column externally?

99封情书 提交于 2019-11-30 04:53:36

问题


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:


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


来源:https://stackoverflow.com/questions/18656034/how-to-hide-show-ng-grid-column-externally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!