Javascript AngularJS UI网格动态覆盖行选择颜色

Javascript AngularJS UI网格动态覆盖行选择颜色,javascript,angularjs,angular-ui-grid,ui-grid,Javascript,Angularjs,Angular Ui Grid,Ui Grid,嗨,当一行被动态选择时,我试图覆盖ui网格的默认颜色,当我选择第一行时,我希望它的颜色与其他选定行的颜色不同 if($scope.mySelections.length==1){ //here overwrite the css .ui-grid-row.ui-grid-row-selected>[ui-grid-row]>.ui-grid-cell{ background-color: #efe8ed!important; } }

嗨,当一行被动态选择时,我试图覆盖ui网格的默认颜色,当我选择第一行时,我希望它的颜色与其他选定行的颜色不同

    if($scope.mySelections.length==1){
     //here overwrite the css
    .ui-grid-row.ui-grid-row-selected>[ui-grid-row]>.ui-grid-cell{
         background-color: #efe8ed!important;
    }
}
我希望这是有意义的。欢迎提出任何建议。这样做的目的是使第一个选定行的外观与之后选定的行的外观不同。
提前谢谢

我相信这可能接近你想要的,梅罗

JavaScript/AngularJS控制器:

app.controller('MainCtrl', ['$scope', '$http', function($scope, $http) {
  var colorRowTemplate =
    //same as normal template, but extra ng-class for firstSelection:  'first-selection':row.entity.firstSelection
    "<div ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{'first-selection':row.entity.firstSelection, 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  $scope.gridOnRegisterApi = function(gridApi) {
    gridApi.selection.on.rowSelectionChanged($scope, function(row) {
      row.entity.firstSelection = false;
      if (row.isSelected) row.entity.firstSelection = (gridApi.selection.getSelectedCount() == 1);
    });
  };
  $scope.gridOptions = {
    enableSelectAll: true,
    enableRowSelection: true,
    enableRowHeaderSelection: false,
    enableFullRowSelection: true,
    rowTemplate: colorRowTemplate,
    showGridFooter: true,
    onRegisterApi: $scope.gridOnRegisterApi
  }
  $http.get('data.json')
    .then(function(response) {
      $scope.gridOptions.data = response.data;
    });
}]);
app.controller('MainCtrl',['$scope','$http',函数($scope,$http){
变量colorRowTemplate=
//与普通模板相同,但firstSelection有额外的ng类:“firstSelection”:row.entity.firstSelection
"";
$scope.gridOnRegisterApi=函数(gridApi){
gridApi.selection.on.rowSelectionChanged($范围,函数(行){
row.entity.firstSelection=false;
if(row.isSelected)row.entity.firstSelection=(gridApi.selection.getSelectedCount()==1);
});
};
$scope.gridOptions={
enableSelectAll:true,
enableRowSelection:true,
enableRowHeaderSelection:false,
enableFullRowSelection:true,
rowTemplate:colorRowTemplate,
showGridFooter:true,
onRegisterApi:$scope.gridOnRegisterApi
}
$http.get('data.json')
.然后(功能(响应){
$scope.gridOptions.data=response.data;
});
}]);
这是一个正在工作的Plunker