Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table: datakey attribute not working correctly in table with expandable rows group #13645

Closed
ZellCorp opened this issue Sep 9, 2023 · 6 comments

Comments

@ZellCorp
Copy link

ZellCorp commented Sep 9, 2023

Describe the bug

Hello !
there the issue :

Using the table component, when datakey value is from a different object than the one used in groupRowsBy
Then, the row group will change to contains only one element except the case where datakey value is undefined.

For exemple consider the following data/domain object :

id: 1000,
representative: {
    name: 'Ioni Bowcher',
    image: 'ionibowcher.png'
 },

This code will work (useless part removed for the explication):

 <p-table dataKey="representative.name"  groupRowsBy="representative.name"></p-table>
OR
 <p-table dataKey="representative.image"  groupRowsBy="representative.name"></p-table>
OR
 <p-table dataKey="representative.x"  groupRowsBy="representative.name"></p-table>
OR
 <p-table dataKey="anyUndefinedValue"  groupRowsBy="representative.name"></p-table>

This code will not (useless part removed for the explication):

 <p-table dataKey="id"  groupRowsBy="representative.name"></p-table>

The bug can be reproduced using the demo from : https://primeng.org/table#expand
Or from the stackblitz link below.

Good luck :)

Environment

Nothing specific.

Reproducer

https://stackblitz.com/edit/yxteqe?file=src%2Fapp%2Fdemo%2Ftable-expandable-row-group-demo.html

Angular version

16.2.0

PrimeNG version

16.3.1

Build / Runtime

TypeScript

Language

TypeScript

Node version (for AoT issues node --version)

18.13.0

Browser(s)

No response

Steps to reproduce the behavior

  1. Go to : https://primeng.org/table#expand
  2. Open the stackblitz exemple
  3. Change the datakey value by 'id'

Expected behavior

We expect to see all data displayed by group and identify them by their id

@ZellCorp ZellCorp added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Sep 9, 2023
@AhmedSaulti
Copy link

Hello,
This PR would really fix a big issue when you try to utilize the grouped rows along with checkbox selection.
The current implementation disregards the unique id of the rows.
Kindly check this PR and if its working, include it in the next patch.

@cetincakiroglu cetincakiroglu added this to the 17.15.0 milestone Apr 18, 2024
@cetincakiroglu
Copy link
Contributor

Hi @ZellCorp @AhmedSaulti ,

A similar issue has been addressed in #14672
I've checked it with the v17.13.0 and this issue is also fixed within this pr. Could you please check it with the v17.13.0 and let us know if it's fixed for good or not?

@cetincakiroglu cetincakiroglu added Resolution: Needs More Information More information about the issue is needed to find a correct solution and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 18, 2024
@AhmedSaulti
Copy link

Hi @cetincakiroglu,
I have tried it using dataKey as the id of the item, it did work. The checkbox works correctly with the main table header checkbox. So as the open issue's scope, its considered fixed to me.

The current challenge is to have a checkbox at the level of the group header which reflects only on the rows of its group, that doesn't go on correctly.

I will try to work on it in a custom manner but if there is a clue about it that its included already, I would appreciate it.

Thanks

@cetincakiroglu
Copy link
Contributor

Hi @cetincakiroglu,

I have tried it using dataKey as the id of the item, it did work. The checkbox works correctly with the main table header checkbox. So as the open issue's scope, its considered fixed to me.

The current challenge is to have a checkbox at the level of the group header which reflects only on the rows of its group, that doesn't go on correctly.

I will try to work on it in a custom manner but if there is a clue about it that its included already, I would appreciate it.

Thanks

Could you please share a stackblitz example about the row issue and tag me so we can investigate

@AhmedSaulti
Copy link

@cetincakiroglu,

Here my friend a demo based on the example, I modified the table header to be a tristate checkbox and wanted to apply the same logic to the group header as well, showing partial and full selection.

https://stackblitz.com/edit/sahfjj?file=src%2Fapp%2Fdemo%2Ftable-expandable-row-group-demo.html

@cetincakiroglu
Copy link
Contributor

Hi @AhmedSaulti,

Unfortunately, that behavior is not supported. All we can do is try monkey patch to find a workaround. We cannot also update the table so it can behave tristate or reflect the group selection. Maybe you can try treatable component for it? Compared to the table, it's easier to utilize checkbox selection in groups with tree table https://primeng.org/treetable#checkbox

However, tristate is not supported in treatable too, you'll still need to find a workaround.

I'm closing the issue since the mentioned bug has already fixed. Could you please open a discussion and share it with the community if you find a workaround with tristate? Maybe someone trying to do same, would be a good example.

@cetincakiroglu cetincakiroglu removed this from the 17.15.0 milestone Apr 26, 2024
@cetincakiroglu cetincakiroglu removed the Resolution: Needs More Information More information about the issue is needed to find a correct solution label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants