Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

246
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda