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

245
Views
How to Compare and Highlight Duplicate Rows in Ag-Grid with react

I'm trying to get ag-grid to highlight duplicate rows by comparing the id, name, and description.

values = [ 
     { id: 10, name: 'axel', desc: 'it's me' }, 
     { id: 10, name: 'axel', desc: 'not me' }, 
     { id: 11, name: 'payton',  desc: 'hello I'm payton'}, 
     { id: 10, name: 'axel', desc: 'it's me' }                         
    ];

the row that will be highlighted should be ...

values = [ 
        { id: 10, name: 'axel', desc: 'it's me' }, 
        { id: 10, name: 'axel', desc: 'it's me' } 
         ];

There may be new objects inserted into the array without an id but I would still like to remove the objects with the same name and description.

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

0

I don't know ag-grid but if you want to find the duplicated object you can do this

const values = [ 
     { id: 10, name: 'axel', desc: "it's me" }, 
     { id: 10, name: 'axel', desc: 'not me' }, 
     { id: 11, name: 'payton',  desc: "hello I'm payton"}, 
     { id: 10, name: 'axel', desc: "it's me" }                         
    ];
    
    
const findDuplicated = data =>  Object.values(data.reduce((res, item) => {
  const key = JSON.stringify(item)
  return {
    ...res,
    [key]: [...(res[key] || []), item]
  }
}, {})).filter(item => item.length > 1).flat()

console.log(findDuplicated(values))


console.log(findDuplicated(values.map(({name, desc}) => ({name, desc}))))

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!