css - Angular UI 网格 : Conditional Row Format Not Overriding Default Alternating Colours

标签 css class angular-ui-grid

对于我的 UI-Grid,我在 $scope.gridOptions 对象中使用以下行模板创建了条件格式:

rowTemplate: '<div ng-class="{\'recruiter-row-active\':row.entity.activePositions!=0, ' +
    '\'recruiter-row-passive\':(row.entity.activePositions==0 && row.entity.passivePositions !=0),' +
    '\'recruiter-row-free\':(row.entity.activePositions==0 && row.entity.passivePositions==0)}">' +
    '<div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name" ' +
    'class="ui-grid-cell" ng-class="{ \'ui-grid-row-header-cell\': col.isRowHeader }" ui-grid-cell></div></div>'

类看起来像这样:

.ui-grid-row .recruiter-row-active {
  background-color: #ff816b !important;
}
.ui-grid-row .recruiter-row-passive {
  background-color: #fcff9d !important;
}
.ui-grid-row .recruiter-row-free {
  background-color: #70cc79 !important;
}

相关 html 行的类是“ui-grid-row”和“ng-scope”,父元素的类是“ui-grid-canvas”

当我还实现了

时,我能够让我的条件格式工作
.ui-grid-row .ui-grid-cell {
  background-color: inherit !important;
}

但是我不想影响我的网络应用程序中的其他网格。

如何让我的条件行格式覆盖默认值?

最佳答案

您可以使用 scss 并用以下内容包裹您的网格:

<div view="my-colors">
    <!-- your grid element goes here -->
</div>

在 scss 文件中,将您希望仅影响该 View 的样式包装为:

[view="my-colors"] {
    .ui-grid-row .ui-grid-cell {
      background-color: inherit !important;
    }
}

关于css - Angular UI 网格 : Conditional Row Format Not Overriding Default Alternating Colours,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51405116/

相关文章:

jquery - Bootstrap 工具提示 : overflow?

c++ - vector 大小在构造函数外恢复为 0

angularjs - 用户界面网格 : How do I set column width when using pdf export

javascript - 在 Ui.grid 中使用 rowTemplate 会禁用 angularjs 中的选择

css - 如何在 div 上正确定位垂直方向的文本?

html - 如何为 HTML 无序列表中的每个列表项分配不同的颜色?

css - 使用 SemanticUI 的边栏和导航栏

python - 如何使用方法更改类属性?

json - Swift 使用参数初始化类,然后在不使用参数的情况下初始化它

javascript - 如何将焦点设置到 'editableCellTemplate' 内使用的自定义指令中的文本字段?