Reputation: 43
I use angularjs ng-grid. I want to add a button for expand/collapse all rows, when ng-grid group by some field. How can I do this?
Upvotes: 1
Views: 3755
Reputation: 5428
The grouped part of ng-grid will probably have a class .ngViewport .ng-scope
This is where you want to add collapse functionality I guess.
Add this div a ng-show
attribute dynamically
$('.ngViewport').attr('ng-show', 'collapsed'); //This is jquery, you can use angular directives for best practice, dont have time :)
Assign it to a button. So whenever you click, it will toggle.
<a href="#" ng-model="collapsed" ng-click="collapsed=!collapsed">Click here to <strong>Toggle (show/hide)</strong> Grid</a>
Upvotes: 1