primereact icon indicating copy to clipboard operation
primereact copied to clipboard

In datatable with rowGroupMode as rowspan, sorting other fields is changing the grouping field

Open sharmillamuthu opened this issue 6 years ago • 5 comments

Current behavior Create datatable with rowGroupMode as rowspan. image

Given the field to group as "brand" and the "year" as sortable column. On sorting "year", grouping is done for "year" column image

Find the sample code in the link below: https://codesandbox.io/s/primereact-test-igm27

Expected behavior On sorting other fields in datatable with rowGroupMode as rowspan, the grouping field should not get changed.

sharmillamuthu avatar May 20 '20 14:05 sharmillamuthu

I am also having the same issue.

Would also be interested in an answer.

tom-son avatar May 21 '20 08:05 tom-son

Hi,

I am not sure about this change. When you change the year value of one of the Audi items (Exp: 2014 instead of 2012 ), how should it be grouped? I think it's a bit confusing.

mertsincan avatar Jun 04 '20 09:06 mertsincan

Hi @mertsincan , The expected behaviour is if "brand" is grouped then while sorting "year" the grouping should be done in the same "brand" field instead of "year". Please find the images for the expected behaviour:

image This is the initial table with "brand" as rowgroup.

image This is the expected output when "year" field is sorted

sharmillamuthu avatar Jun 16 '20 09:06 sharmillamuthu

Just perusing the backlog. This ask is definitely wrong and goes against the general consensus of what GroupBy and SortBy in database should mean.

What @sharmillamuthu is asking for is Sorting by multiple keys.

See this CodeSandbox with the configurations that you want. This can be done by manipulating the multiSortMeta object as needed to prioritize the order as you see fit.

I'd recommend that this issue be closed out.

bweis avatar Nov 03 '23 17:11 bweis

Thanks @bweis marked as Workaround provided!

melloware avatar Nov 03 '23 17:11 melloware