UI-GRID header - Change Color And Text

喜欢而已 提交于 2019-12-10 14:23:54

问题


I want to change the color and text of the angular ui-grid header.

I want the background of the header to be black and the text to be white.

I don't want gradient or shading. I just want it black.

What CSS do I need to add?


回答1:


This is pretty simple. Just add a headerCellClass for each column with your css.

 $scope.gridOptions = {
    enableSorting: true,
    columnDefs: [
      { field: 'name', headerCellClass: 'white' },
      { field: 'company',headerCellClass:'white'}
    ],
    onRegisterApi: function( gridApi ) {
      $scope.gridApi = gridApi;
      $scope.gridApi.core.on.sortChanged( $scope, function( grid, sort ) {
        $scope.gridApi.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );
      })
    }
  };

here's a sample

http://plnkr.co/edit/DKi9nSMbI3PG1u8lcHDE?p=preview




回答2:


I know this is already answered. But this css rule does the same job without the need of creating columDefs:

.ui-grid-top-panel {
    background: black;
    color: white;
}

Plunker




回答3:


If you need to change the background color of all ui-grid header use the following in your CSS file.

.ui-grid-header-canvas{
    background-color: black;
}
.ui-grid-top-panel{
    color: white;
}

Otherwise, if you need to change the background color of specific ui-grid headers, then use headerCellClass attribute.



来源:https://stackoverflow.com/questions/30583429/ui-grid-header-change-color-and-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!