cellClass不适用于角度ui网格

时间:2016-08-29 08:38:10

标签: javascript css angularjs angular-ui-grid ui-grid

这是我的代码:

for (var i = 0; i < gridData.length; i++) {
    var currentData = gridData
    $.each(currentData, function(key, value) {
        if (!angular.isFunction(value)) {
            $scope.columnDefs.push({
                name : key,
                cellClass : 'red',
            });
        }
    });
}
$scope.gridOptions = {
    columnDefs : $scope.columnDefs
};
$scope.gridOptions.data = data;
.red{
	background-color: #ff0000;
	color: #ffffff; 
}
<div ng-controller="GridController" id="grid1">
     <div  ui-grid="gridOptions" class="grid"></div>
</div>

当我从cellClass数组中替换columnDefs属性时,它绝对正常工作但是当我向cellClass数组添加columnDefs属性时,我的网格不显示数据。在检查ui-grid dom时,我的数据与ui-grid cell绑定,但未显示在ui上。

2 个答案:

答案 0 :(得分:0)

简单地在ui.grid.css

中覆盖这两个css类

&#13;
&#13;
   .ui-grid-row:nth-child(odd) .ui-grid-cell {

}
.ui-grid-row:nth-child(even) .ui-grid-cell {

} 
&#13;
&#13;
&#13;

从ui-grid.css

中的上述css类中删除背景色css

答案 1 :(得分:0)

使用cellTemplate代替cellClass

示例:

cellTemplate: "<div class='red'>{{COL_FIELD}}</div>"