bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
53 stars 6 forks source link

Id collision after `clearGroups` and `loadData` again #10081

Open chuckn0rris opened 1 week ago

chuckn0rris commented 1 week ago

Forum post

Hi I'm trying to use the tree-grouping feature, and would like to sometimes turn-off grouping and reload the resourceStore with new data... I have reloaded the resourceStore with the same procedure in the past with great success, but since adding the grouping feature have encountered an error, here is a way to reproduce it:

https://www.bryntum.com/products/scheduler/examples/tree-grouping/

in the console do the following steps to temporarily stop grouping and reload with new data ( NOTE: in our data we have pre-defined IDs and cannot assign new ones, we must be able to clear and reload on demand when the data changes... ):

#1 - pretend to have new data by saving a copy of the old data:
newData = scheduler.resourceStore.data.slice()

#2 - clear the groups (NOTE: not strictly necessary, will error without this step):
scheduler.clearGroups()

#3 - clear the data:
scheduler.resourceStore.removeAll()

#4 - add new data:
scheduler.resourceStore.loadDataAsync(newData)

Promise {<rejected>: Error: Id collision on 2
    at ResourceStore.register (https://www.bryntum.com/products/scheduler/…}

Uncaught (in promise) Error: Id collision on 2
    at ResourceStore.register (scheduler.module.js?479503:310:843256)
    at f.joinStore (scheduler.module.js?479503:310:607114)
    at f.joinStore (scheduler.module.js?479503:310:855456)
    at scheduler.module.js?479503:310:544202
    at Array.forEach (<anonymous>)
    at scheduler.module.js?479503:310:544180
    at Array.forEach (<anonymous>)
    at f.internalAppendInsert (scheduler.module.js?479503:310:544095)
    at f.insertChild (scheduler.module.js?479503:310:541877)
    at f.appendChild (scheduler.module.js?479503:310:541198)
register @ scheduler.module.js?479503:310
joinStore @ scheduler.module.js?479503:310
joinStore @ scheduler.module.js?479503:310
(anonymous) @ scheduler.module.js?479503:310
(anonymous) @ scheduler.module.js?479503:310
internalAppendInsert @ scheduler.module.js?479503:310
insertChild @ scheduler.module.js?479503:310
appendChild @ scheduler.module.js?479503:310
loadTreeData @ scheduler.module.js?479503:310
setStoreData @ scheduler.module.js?479503:310
setStoreData @ scheduler.module.js?479503:310
set data @ scheduler.module.js?479503:310
loadDataAsync @ scheduler.module.js?479503:310

Thanks for any help, Jeff