Carlos F. Montano
Carlos F. Montano

Reputation: 21

Ng-grid show/hide column conditionally

I am using ng-grid, and need to show or hide the contents of one column based on the contents of another column on each row. If the field is false, I want to show the icon, otherwise I want to show nothing on that column. I use a service to get the data for the grid. When I get the data, I know whether to make this column visible or not.

I have tried to do this

$scope.gridOptions.columnDefs[$scope.CustomHIVROnlyPosition].visible = false;

at that time, but $scope.gridOptions is undefined. There’s got to be a way to do this and I have tried a few things without any luck. Any suggestions would be greatly appreciated.

Upvotes: 2

Views: 6774

Answers (1)

Rani Radcliff
Rani Radcliff

Reputation: 5084

Try this:

$scope.gridOptions.columnDefs[0].visible = $scope.falsy;

replace the "0" with the number of the column you wish to hide, then make it equal to something that will be false. You can get the other cell value with something like grid.getCellValue(row,col).

Hope this helps!

Upvotes: 2

Related Questions