Juan Caicedo
Juan Caicedo

Reputation: 1523

ag-grid change class or change style to RowNode

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

Answers (1)

Paritosh
Paritosh

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.

  1. 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.

  1. 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

Related Questions