根据其他节点或行值的情况动态更改 AG 网格先前的 cellStyle
Change AG grid previous cellStyle dynamically based on condition of other nodes or row value
我可以根据当前节点的某些条件更改当前的 cellStyle。但是我必须根据当前节点中的某些条件更改前一个 cellStyle。
columnDefs = [
{ headerName: "TripStatus", field: "TripStatusCode",cellStyle: this.cellStyling},
]
调用以下方法动态改变样式
cellStyling(params:any){
// This will change the current cell style only. But I need to change the style of immediate previous cell style.
if(params.node.TripStatusCode==='CO')
return {'background-color': 'red'};
}
cellClassRules = {
'your-css-class': params => {
if (params.colDef.field === "myCurrentField" &&
params.data["previousField"] === "value") {
return true;
} else {
return false;
}
},
'your-other-css-class': params => {return false}
}
您可以根据需要定义任意多的 class 规则,只需用逗号分隔,函数应该 return true/false.
我可以根据当前节点的某些条件更改当前的 cellStyle。但是我必须根据当前节点中的某些条件更改前一个 cellStyle。
columnDefs = [
{ headerName: "TripStatus", field: "TripStatusCode",cellStyle: this.cellStyling},
]
调用以下方法动态改变样式
cellStyling(params:any){
// This will change the current cell style only. But I need to change the style of immediate previous cell style.
if(params.node.TripStatusCode==='CO')
return {'background-color': 'red'};
}
cellClassRules = {
'your-css-class': params => {
if (params.colDef.field === "myCurrentField" &&
params.data["previousField"] === "value") {
return true;
} else {
return false;
}
},
'your-other-css-class': params => {return false}
}
您可以根据需要定义任意多的 class 规则,只需用逗号分隔,函数应该 return true/false.