Paul Witherspoon
Paul Witherspoon

Reputation: 221

ng-grid how to remove auto generated aggregate/grouping columns

Does anyone know how can I remove the auto-generated columns that are added whenever a grouping is added to the ng-grid? The columns are blank and appear at the left hand side and are around 30px wide. There are one of these columns per grouping (so if I grouped on 5 fields I would have 5 of these blank columns and it really throws my formatting).

EDIT: I am including a plunker from the ng-grid website to illustrate the issue - for each column "grouped by" an extra auto-generated column appears on the left hand side of the grid.

http://plnkr.co/edit/Bp2h2Lg6YzJoMbjocgg2?p=info

Upvotes: 0

Views: 2345

Answers (2)

Mohamed NAOUALI
Mohamed NAOUALI

Reputation: 2132

Just add showTreeRowHeader: false, to your grid option

Upvotes: 1

Paul Witherspoon
Paul Witherspoon

Reputation: 221

I figured it out. I had to use the ndGridEventGroups event.

    $scope.$on('ngGridEventGroups', function (newColumns) {

        var log = [];
        angular.forEach(newColumns.targetScope.columns, function (value) {
        if (value.isAggCol != undefined)
            {value.visible = !value.isAggCol;}

        }, log);

    });

then for css you need to use (note you need to replace "table" with whatever html object you are using in your aggregate template - obviously, mine was a table :)

<style type="text/css">
span.ngAggregateText {left:0px !important;}
table.ngAggregate {left:0px !important;}
</style>

Upvotes: 0

Related Questions