Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
React AgGrid - Row Style based on conditions from the props

I am using AgGrid for React and I am using class-style react components - not functional components.

My goal is to render the cellStyle based on props conditions.

However, when I want to render it, it renders without even the props are loaded.

How can I fix this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You probably want to call GridApi.refreshCells() to apply the change after updating the column's cellStyle:

const columnDefs = React.useMemo(
  () => [
    {...}
    {
      headerName: "Age",
      field: "age",
      cellStyle: props.styles
        ? { backgroundColor: "pink" }
        : { backgroundColor: "white" }
    }
  ],
  [props.styles]
);

React.useEffect(() => {
  gridApi?.refreshCells({ force: true });
}, [props.styles]);

Live Demo

Class component

Codesandbox Demo

Functional component

Codesandbox Demo

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!