ng-grid headerRowTemplate - Has anyone used this?
Asked Answered
A

1

7

My team are wanting to use this feature of ng-grid. However it does not seem to be documented anywhere. What we would like to do is to put a "plus" icon into the last column of the header area of a ng-grid.

Has anyone found a good way to do this?

Acquirement answered 20/4, 2013 at 9:47 Comment(1)
If my answer below helped you answer your question, please consider marking it as the accepted answer...thank you!Dunsany
D
6

Just modify the headerCellTemplate for the last column in your grid (see https://github.com/angular-ui/ng-grid/wiki/Templating).

Here is an example (note <img src="PLUS-ICON.png" /> in the second line):

var myHeaderCellTemplate = '<div class="ngHeaderSortColumn {{col.headerClass}}" ng-style="{\'cursor\': col.cursor}" ng-class="{ \'ngSorted\': !noSortVisible }">' +
                           '<div ng-click="col.sort($event)" ng-class="\'colt\' + col.index" class="ngHeaderText">{{col.displayName}} <img src="PLUS-ICON.png" /></div>' +
                           '<div class="ngSortButtonDown" ng-show="col.showSortButtonDown()"></div>' +
                           '<div class="ngSortButtonUp" ng-show="col.showSortButtonUp()"></div>' +
                           '<div class="ngSortPriority">{{col.sortPriority}}</div>' +
                           '<div ng-class="{ ngPinnedIcon: col.pinned, ngUnPinnedIcon: !col.pinned }" ng-click="togglePin(col)" ng-show="col.pinnable"></div>' +
                           '</div>' +
                           '<div ng-show="col.resizable" class="ngHeaderGrip" ng-click="col.gripClick($event)" ng-mousedown="col.gripOnMouseDown($event)"></div>';
$scope.gridOptions = {
    data: self.myData,
    columnDefs: [
        { field: 'firstField', displayName: 'First Column' },
        { field: 'secondField', displayName: 'Second Column' },
          ...
        { field: 'lastField', displayName: 'Last Column', headerCellTemplate: myHeaderCellTemplate }
    ]
};
Dunsany answered 25/10, 2013 at 17:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.