primereact icon indicating copy to clipboard operation
primereact copied to clipboard

DataTable: Grouping rows generate repeated groups

Open alvarorodriguezestruch opened this issue 1 year ago • 6 comments

Describe the bug

When setting the groupRowsBy propety, it generate repeated groups.

Reproducer

https://stackblitz.com/edit/fxzaak?file=src%2FApp.jsx

PrimeReact version

10.6.6

React version

18.x

Language

TypeScript

Build / Runtime

Next.js

Browser(s)

Chrome 126

Steps to reproduce the behavior

  1. Click on the top bar "Agrupar por..." dropdown and choose "Activo"

Expected behavior

It should generate only two groups, one for "Activo" and "Inactivo".

alvarorodriguezestruch avatar Jun 13 '24 19:06 alvarorodriguezestruch

@alvarorodriguezestruch Were you able to exact this issue for this or some hacky fix . I am getting the same issue in my data

Shreyans13 avatar Aug 02 '24 15:08 Shreyans13

Not sure if that is expected or not, but when grouping if you disable the pagination and sorts by the column you are grouping, is the only way I found to create unique groups

alvarorodriguezestruch avatar Aug 03 '24 08:08 alvarorodriguezestruch

@alvarorodriguezestruch Thanks I will try the same. Is there any discord channel or somethings where maintainers can be contacted to check it its really a issue

Shreyans13 avatar Aug 04 '24 17:08 Shreyans13

There is a Discord channel it's posted right on the main PrimeReact GitHub page

However PrimeTek does not really monitor them it's for community members to support other community members.

melloware avatar Aug 04 '24 18:08 melloware

@melloware Did you check by any chance if its an issue or not or if there is some prop passing issue ?

Reproducer (by @alvarorodriguezestruch ) https://stackblitz.com/edit/fxzaak?file=src%2FApp.jsx

Shreyans13 avatar Aug 05 '24 07:08 Shreyans13

I have only seen it work where the group by field has to be the same as it's sorted. So no property that I know of. So I am not sure if it is by design or not.

melloware avatar Aug 05 '24 10:08 melloware

Just wanted to share how I worked around this bug.

As melloware mentioned I guess we need the data to be sorted by the field we are grouping by.

So in my case I had 6 objects and the groupByField was for scheduleType. Initially i had it this way: [0,1,1,0,1,0]

With that kind of data it would create duplicate groupings, But when I sorted it to have it this way: [0,0,0,1,1,1]

The duplicate groupings went away.

JosuerBague avatar Jan 21 '25 08:01 JosuerBague