Replies: 1 comment 8 replies
-
Hmm I was hoping to never touch this code again, it took me near 6 months to get Tree Data working with all features that I wanted. I agree that calling this function more than once shouldn't impact its final array or should at the very least also provide the same output. However, it is important to note that the function does mutate the input array as it was mentioned in the JSDocs, but yes the result should always be the same and not add extra rows on the second run. But even then, the question would be why are you mounting it twice? Can't you make sure that you only mount the component once and avoid performing the same execution? I'm saying this because dealing with the Tree Data multiple time can be costly, I think I already mentioned that in your other discussion but... Side note, SlickGrid doesn't support Tree Data by itself, it can only deal with flat data, so the way I got it working is to keep copies of both the flat and hierarchical arrays and then keep them in sync whenever a CRUD operation comes in. So having to recreate both arrays (flat/hierarchical) multiple times is something you should avoid redoing too often because it can become costly in terms of performance are you able to provide copies of the data? I think the first troubleshooting would be to see what happens when you run this function twice on the same array, I'm assuming the 2nd run modifies the array. If you can't provide the data, then you could try to troubleshoot it on your side by running the same function oh and yeah I saw you mentioned Hello Team earlier, there's no team here, it's just me, welcome to the world of open source 😅 |
Beta Was this translation helpful? Give feedback.
-
I'm currently investigating an issue that arises when I mount my SlickGrid Tree Data as a React component for the second time. The problem occurs when I toggle between different data view formats in my application. Specifically, switching away from the Tree Data view and then returning to it results in a failure of the Tree Data Component.
The data set I’m working with follows a Parent/Child structure, where the
id
andparentId
fields are of typestring
.(It would be helpful to include a note in the documentation indicating the preferred or faster data input method.)
The SlickGrid Tree Data Grid throws the following error:
Upon investigation, I discovered that on the second mount (not just a second render), one of the internal data mutation functions introduces duplicates into my data set. This causes the
ensureIdUniqueness
function to fail.The issue seems to be related to the function located here:
slickgrid-universal/packages/common/src/services/utilities.ts
Line 158 in ce8b400
This specific loop appears to be introducing duplicates:
slickgrid-universal/packages/common/src/services/utilities.ts
Lines 173 to 187 in ce8b400
I'm continuing to investigate the root cause, but since this issue only occurs on the second mount, I haven’t yet identified any obvious side effects. If this is something you’ve encountered before, I would greatly appreciate any insights or suggestions you could share.
Thank you for your assistance.
Best, Tomasz
Beta Was this translation helpful? Give feedback.
All reactions