[转]UI-Grid HeaderCellClass
2018-01-24 10:41
337 查看
本文转自:http://blog.csdn.net/vesong87/article/details/69230476
原文: 115 HeaderCellClass
在columnDef中可以为每个列表头 设置一个class名称或者通过function返回的一个class名称。
在下面例子中,我们可以设置第一列的字体颜色为蓝色,第二列当排序条件为ASC时字体颜色和背景色改变。
代码:
index.html
main.css
app.js
Demo
原文: 115 HeaderCellClass
在columnDef中可以为每个列表头 设置一个class名称或者通过function返回的一个class名称。
在下面例子中,我们可以设置第一列的字体颜色为蓝色,第二列当排序条件为ASC时字体颜色和背景色改变。
代码:
index.html
<!doctype html> <html ng-app="app"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-touch.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script> <script src="http://ui-grid.info/docs/grunt-scripts/csv.js"></script> <script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script> <script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script> <script src="/release/ui-grid.js"></script> <script src="/release/ui-grid.css"></script> <script src="app.js"></script> </head> <body> <div ng-controller="MainCtrl"> <br> <br> <div id="grid1" ui-grid="gridOptions" class="grid"></div> </div> </body> </html>
main.css
.grid { width: 500px; height: 200px; } .red { color: red; background-color: yellow !important; } .blue { color: blue; }
app.js
var app = angular.module('app', ['ngAnimate', 'ngTouch', 'ui.grid']); app.controller('MainCtrl', ['$scope', '$http', 'uiGridConstants', function ($scope, $http, uiGridConstants) { $scope.gridOptions = { enableSorting: true, columnDefs: [ { field: 'name', headerCellClass: 'blue' }, { field: 'company', headerCellClass: function(grid, row, col, rowRenderIndex, colRenderIndex) { if (col.sort.direction === uiGridConstants.ASC) { return 'red'; } } } ], onRegisterApi: function( gridApi ) { $scope.gridApi = gridApi; $scope.gridApi.core.on.sortChanged( $scope, function( grid, sort ) { $scope.gridApi.core.notifyDataChange( uiGridConstants.dataChange.COLUMN ); }) } }; $http.get('/data/100.json') .success(function(data) { $scope.gridOptions.data = data; }); }]);
Demo
相关文章推荐
- 十四、UI-Grid HeaderCellClass
- 十、UI-Grid CellClass
- 改写ui-grid headerCellTemplate
- class="ui-grid-a"
- ADF(UI)--别忘了<af:table>中<af:column>中的headerClass属性
- ElementUI之cell-class-name 使用方法
- 黄聪:jquery.bootgrid表格插件有的属性(visibleInSelection、cssClass、headerCssClass、headerAlign)不能识别的解决办法
- angularjs ui-grid cellTemplate checkbox ng-checked
- 如何在gridx的cell中显示控件?
- ui-grid 使用讲解
- class="ui-btn"指定居中格式
- 让Kendoui Grid多字段排序
- easy ui grid的简单应用
- jQuery Mobile中按钮<a>或<button>添加class样式ui-btn-*
- UI 09 自定义cell
- ComponentArt.web.ui中文帮助之Grid(六)
- UI Automation-GridPattern
- CGridCtrl、CGridCellCombo和CGridCellCheck
- Qt Style Sheet(六) --- QTextTableCell Class Reference