DataTable shows incorrect or duplicated data after updating rows in responsive mode
DataTable shows incorrect or duplicated data after updating rows in responsive mode
Link to test case:https://stackblitz.com/~/github.com/mizterdy07/vue3-test-datatable?file=src/App.vue&view=editor
Error messages shown:
Before Click Button Change

After Click Button Change

Description of problem: When the DataTable is in responsive mode (tablet or mobile) and the row details are expanded, updating the table data causes the table to switch back to the desktop layout and display duplicate data in previously hidden columns
This question has an accepted answers - jump to answer
Answers
If I'm understanding correctly, to see the problem:
I'm not seeing that behaviour I'm afraid. Clicking the button doesn't change the layout of the table for me. I continue to see 4 columns.
Allan
Let me clarify the issue again:
First, I opened the web page and resized the screen to 550px. At this width, four columns were hidden. Then, I clicked the Expand button to view the hidden columns (see the picture below).

After that, I clicked the Change Data button, which updates the values in the Description column to “11112222”. When I resized the screen back to the normal width of 1070px, the four previously hidden columns reappeared — but their data was duplicated (see the picture below).

Hi,
Thanks for the instructions. I went to look at it, but, have you changed the Stackblitz example? This is what I'm seeing at the moment:
I no longer see the "Change Data" button, and the data is different.
How can I see the original issue please?
Allan
"Did you click this link: https://stackblitz.com/~/github.com/mizterdy07/vue3-test-datatable?file=src/App.vue?
That's odd - yes, it is back to normal now. Maybe I did click on the wrong one... Anyway, I see the issue now, thank you.
The problem is that when clicking the
Change Databutton, the data is updated, but Responsive doesn't clear out its child node cache. So when the table is expanded, the elements that were hidden are reattached, even although they are no longer needed.As a total hack, a workaround is to add:
at the end of your
fnUpdatefunction. That eliminates the child node cache.That isn't a great solution though - I need to look into a better way to resolve this, ideally making it happen automatically. I will do so as part of other changes that I'm working on (although they are extensive, so it won't be resolved properly in the near future I'm afraid).
Allan
Thank you very much, Allan, for resolving the issue.