admin管理员组文章数量:1287514
I want to change the background color of the row in my kendo-grid whenever I select it. Currently, my HTML code looks something like this:
<kendo-grid id="kendoGridId"
[kendoGridBinding]="something"
[loading]="loading"
[selectedKeys]="selectedKeys"
[selectable]="true"
[height]="124"
[resizable]="true"
[sortable]="true"
(cellClick)="onSelect($event)"
kendoGridSelectBy="id">
...
The code works, I select a row using cellClick. However, the row turns light blue whenever I select it but I want it to be transparant.
I have already turned off my encapsulation by adding encapsulation: ViewEncapsulation.None
to my .ts file. According to google, something like :
:host ng-deep .k-state-selected {
background-color: red !important;
}
should work, but it doesnt. Also tried using without :host and ::ng-deep, but that also does not work. Also tried adding it to the global .scss file, still nothing. Anyone have any idea? When trying to change the background color when hovering over the row, this did work :
.k-grid tr:hover {
background-color: white; /* Change this to your desired color */
}```
so I am curious why it does not work for selecting rows.
I want to change the background color of the row in my kendo-grid whenever I select it. Currently, my HTML code looks something like this:
<kendo-grid id="kendoGridId"
[kendoGridBinding]="something"
[loading]="loading"
[selectedKeys]="selectedKeys"
[selectable]="true"
[height]="124"
[resizable]="true"
[sortable]="true"
(cellClick)="onSelect($event)"
kendoGridSelectBy="id">
...
The code works, I select a row using cellClick. However, the row turns light blue whenever I select it but I want it to be transparant.
I have already turned off my encapsulation by adding encapsulation: ViewEncapsulation.None
to my .ts file. According to google, something like :
:host ng-deep .k-state-selected {
background-color: red !important;
}
should work, but it doesnt. Also tried using without :host and ::ng-deep, but that also does not work. Also tried adding it to the global .scss file, still nothing. Anyone have any idea? When trying to change the background color when hovering over the row, this did work :
.k-grid tr:hover {
background-color: white; /* Change this to your desired color */
}```
so I am curious why it does not work for selecting rows.
Share
Improve this question
asked Feb 23 at 19:50
user29759359user29759359
1
1 Answer
Reset to default 0Try changing this : :host ng-deep .k-state-selected
by this :host ::ng-deep .k-state-selected
.
Another approach would be to put this CSS directly into the main styles file of your Angular project while being as precise as possible.
Ex:
[app.class] [component.class] .k-state-selected { background-color: red !important; }
本文标签: typescriptChange background color of selected row in Angular using kendogridStack Overflow
版权声明:本文标题:typescript - Change background color of selected row in Angular using kendo-grid - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741304720a2371299.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论