问题描述
我要将红色应用于其completedhours列值大于24的行.我该怎么做.请帮助我,我是新来的.
I want to apply red color to row whose completedIn hours column value is greater than 24. how can i do it. please help i am new to angular.
<kendo-grid [kendoGridBinding]="gridData">
<kendo-grid-column field="RequestNumber" title="Request No."
width="110" >
</kendo-grid-column>
<kendo-grid-column field="RequestNumber" title="Request No." width="110" >
</kendo-grid-column>
<kendo-grid-column field="Name" title="Name." width="110" >
</kendo-grid-column>
<kendo-grid-column field="CompletedIn" title="CompletedIn" width="110" >
</kendo-grid-column>
</kendo-grid>
推荐答案
首先:您必须将[rowClass]
添加到网格中
First: you have to add [rowClass]
to your grid
<kend-grid [rowClass]="rowCallback">
</kendo-grid>
然后您需要在组件内部添加函数并返回所需的类
then you need to add the function inside the component and return the needed class
public rowCallback(context: RowClassArgs) {
if (context.dataItem.someProperty) { // change this condition as you need
return {
passive: true
};
}
}
最后,您需要有一个CSS类,其名称为您返回的名称(在本例中为passive
,但您当然可以根据需要进行更改)
and last you need to have a CSS class with the name you returned,(in this case passive
but of course you can change it as you want)
@Component({
selector: "your-component",
templateUrl: "./your.component.html",
encapsulation: ViewEncapsulation.None,
styles: [
`
.k-grid tr.passive {
background-color: lightgray;
}
`
]
})
使用encapsulation: ViewEncapsulation.None
并使用前缀.k-grid tr
命名该类非常重要,否则您将无法获得所需的结果
it is very important to use encapsulation: ViewEncapsulation.None
and name the class with the prefix .k-grid tr
otherwise you will not get the needed result
这篇关于如何根据剑道网格中的特定列条件更改行的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!