ng-grid – Dynamically Setting Group by One or More Fields

June 17, 2014

in one of LogoUi’s projects we had a requirement for dynamically grouping data,  trying to dynamically group data using the group property , is ignored, so after examining the ng-grid internal code, i found a solution. Setting group by one field for grouping by one field, in grid options object you need to call the groupBy function and pass the field as a string argument . Example:html: <div ng-controller="MyCtrl"> <button type="button" ng-click="changeGroupBy('name')">Group By Name</button> <button type="button" ng-click="changeGroupBy('age')">Group By Age</button> <div class="gridStyle" ng-grid="gridOptions"></div> </div> JavaScript: app.controller('MyCtrl', function($scope) { $scope.myData = [{"name": "Moroni", "age": 50}, ...
one comment