Reputation: 1523
I am trying to change styles using NodeRow
object but it does not have access to the element
api.getSelectedNodes().forEach((node)=>{
if(node.data.isGreen)
node.rowClass.addClass(['.is-selected-green']) // something like this
})
Is there any way to change class using NodeRow
?
Upvotes: 2
Views: 2159
Reputation: 11560
There is a way, but not the way you are expecting.
First of all, we cannot access RowNode
's DOM programmatically to update its CSS class.
Follow below steps.
Set rowClassRules
property of gridOptions
.
gridOptions.rowClassRules = {
'is-selected-green': (params) => {
// try accessing this.otherMethod() here
return params.data.isGreen;
}
// all other classes and their rules
};
All the rows having isGreen
property true
will be having is-selected-green
property on it.
When you select any row, ag-row-selected
will be applied to it, so use below CSS to make it look different.
.is-selected-green.ag-row-selected {
// any style
}
Upvotes: 3