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

DataTable expanded rows collapse when modifying one property of a record #884

Closed
winterspan opened this issue May 13, 2019 · 3 comments
Closed
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@winterspan
Copy link

I'm submitting a ...

[X] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57
``
**Current behavior**
If you are using the row expansion feature, and saving the expanded row data in the state (as demonstrated here https://www.primefaces.org/primereact/#/datatable/rowexpand), all of the expanded rows will collapse if any of the records' fields are changed when passing them in from Redux. 

It seems like the table loses track of the mapping between the expanded row data and the modified record data being passed in as a prop to 'values'. 

**Expected behavior**
Expanded rows should not collapse when the records passed in to the table are not new, just one or more fields modified.

**Minimal reproduction of the problem with instructions**
1) Setup Prime React DataTable with expander column. Records should be provided from redux state slice.
2) expand row
3) have a button in the expanded row update a field on one of the records through a redux action/reducer.
4) You'll notice the row collapses, despite the expandedRowData still being present.

https://codesandbox.io/s/m752k9jq8y

**Please tell us about your environment:**
Windows/IntelliJ/Tomcat

* **React version:**
16.8.3

* **PrimeReact version:**
2.0.1

* **Browser:**
ALL 
 
* **Language:**
ES6/7
@cagataycivici cagataycivici added the Type: Bug Issue contains a defect related to a specific component. label May 30, 2019
@cagataycivici
Copy link
Member

This is expected, we need to keep a key of the records that does not change to uniquely identify it so that if a property changes it is still displayed as expanded.

@cagataycivici cagataycivici added this to the 3.1.4 milestone May 30, 2019
@cagataycivici cagataycivici self-assigned this May 30, 2019
@cagataycivici cagataycivici changed the title DataTable expanded rows collapse when modifying one property of a record (using Redux) DataTable expanded rows collapse when modifying one property of a record May 30, 2019
@cagataycivici
Copy link
Member

With 3.1.4, expandedRows can work with dataKeys so if you define a dataKey problem will be resolved.

@winterspan
Copy link
Author

With 3.1.4, expandedRows can work with dataKeys so if you define a dataKey problem will be resolved.

Excellent. I had just forked the project and started implementing a key based approach. Will give 3.1.4 a try. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

No branches or pull requests

2 participants