angularjs ng-grid: how to change header style
Asked Answered
P

2

6

How can I restyle the header of ng-grid? In particular how can I change the background-color and the text color of the header row?

Physical answered 2/7, 2014 at 20:37 Comment(1)
May I ask why the -1?Physical
C
5

You can override the background-color property on the .ngHeaderCell class declared in the ng-grid.css to use the background color you want on the header cells.

If you don't want to modify the original ng-grid css, you can create your own css and load it after ng-grid's css in which you can later overide the same .ngHeaderCell class with:

.ngHeaderCell {
    background-color: [your background color] !important;
    bottom: 0;
    color: [your foreground color] !important;
    position: absolute;
    top: 0;
}
Cookhouse answered 2/7, 2014 at 20:59 Comment(3)
Thank you! My bad, I could not figure out which was the css class to modify. And I was trying to play around with headerCellTemplate. This worked perfectly.Physical
You're welcome. Firebug and its equivalents always come in handy in these cases. You can inspect an element you want to check and there is a panel in which Firebug shows you which CSS rules are applied to that element and where those rules come from.Cookhouse
I ended up overriding the background-color on the .ngTopPanel classPhysical
F
2

I haven't looked into ng-grid before, but looks like a css file is provided for styling? I would advise either changing the actual css file, or over-writing these changes by declaring your own below where the grid.css is declared. Check link if that is what you are talking about.

https://github.com/angular-ui/ng-grid/blob/master/ng-grid.css

For instance, one of the css attributes in the above file is below, just do a ctrl-f and find the attributes you are looking to change.

.ngHeaderCell {
    position: absolute;
    top: 0;
    bottom: 0;
    background-color: inherit;
 }
Faxun answered 2/7, 2014 at 21:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.