简体   繁体   English

Angular 剑道网格:所选行的背景颜色

[英]Angular Kendo Grid: Background Color of Selected Row

How do I change the background color of Kendo Angular Grid row that is Selected?如何更改选中的剑道 Angular 网格行的背景颜色? The following is not making the background color blue.以下不是使背景颜色变蓝。 Trying to figure out what is overriding it.试图找出压倒它的东西。

.k-grid .k-state-selected  {
  background-color: blue !important;
  color: green;
}
 
.k-grid .k-alt.k-state-selected {
  background-color: blue !important;
  color: green;
}

在此处输入图像描述

Resources: https://www.telerik.com/forums/changing-color-of-selected-row资源: https://www.telerik.com/forums/changeing-color-of-selected-row

Your styling doesn't affect the grid due to view encapsulation.由于视图封装,您的样式不会影响网格。 You can read more about it here .你可以在这里阅读更多关于它的信息。

To force the use of your custom styling into a child component that has view encapsulation, which is set to Emulated by default for all components, add ::ng-deep before the CSS selector, like this:要强制将自定义样式用于具有视图封装的子组件(默认情况下所有组件都设置为 Emulated),请在Emulated选择器之前添加::ng-deep ,如下所示:

:host ::ng-deep .k-grid .k-state-selected  {
    background-color: blue !important;
    color: green;
}
  
:host ::ng-deep .k-grid .k-alt.k-state-selected {
    background-color: blue !important;
    color: green;
}

Since ::ng-deep convert the styling into a global rule, you need to add :host before it so that it will affect only the current component and its children.由于::ng-deep将样式转换为全局规则,因此您需要在它之前添加:host以便它只影响当前组件及其子组件。

Note that ::ng-deep is deprecated and technically shouldn't be used.请注意::ng-deep已弃用,从技术上讲不应使用。 A replacement is planned and ::ng-deep will probably be around until they come up with something else.计划进行替换,并且::ng-deep可能会出现,直到他们想出其他东西。

You can read more about ::ng-deep here .您可以在此处阅读更多关于::ng-deep信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM