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

TypeError: Cannot read properties of undefined (reading 'model') when updating rows and tasks #227

Open
gubeils opened this issue Jun 20, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@gubeils
Copy link

gubeils commented Jun 20, 2024

I am encountering an issue when updating the rows and tasks in svelte-gantt version "^4.3.2". I receive the following error:

TypeError: Cannot read properties of undefined (reading 'model')

image

Here is a screenshot of my rows and tasks data:
image

I am using the method gantt.set({ rows, tasks }) to update the data.

@ANovokmet ANovokmet added the bug Something isn't working label Jun 24, 2024
@ANovokmet ANovokmet self-assigned this Jun 24, 2024
@ANovokmet
Copy link
Owner

Any chance you could provide the error call stack?

@gubeils
Copy link
Author

gubeils commented Jun 25, 2024

image

image

image

image

@ANovokmet
Copy link
Owner

Thank you. While I am fixing the issue, for an immediate fix, you can try checking if you are setting a task with a resourceId for a row that does not exist.

@roman-yukhno-axon
Copy link
Contributor

roman-yukhno-axon commented Jul 17, 2024

Are there any updates? I faced the same problem. Tasks contain only existing resourceId.

UPD: I noticed that my tasks had two item with the same id.
But the issue is still exists when I try to reset rows and tasks by passing empty arrays. It causes only when gantt had rows and tasks before

gantt.$set({ rows: [], tasks: [] });

image

UPD2: I don't know how it works, but resetting in this way works (when I reset tasks at first, and then reset rows in the queue, exactly in this sequence). And then I can fill it together again (again in the queue)

gantt.$set({ tasks: [] });
setTimeout(() => gantt.$set({ rows: [] }), 0);

setTimeout(() => gantt.$set({ rows, tasks }), 0);

@ANovokmet
Copy link
Owner

ANovokmet commented Aug 8, 2024

@roman-yukhno-axon I was testing this on v4.4.2 that was just released and it seems like using gantt.$set({ rows: [], tasks: [] }); does not cause any errors. Could you try again? Setting rows: [] when there are tasks still causes errors and I will work on this further.

ANovokmet added a commit that referenced this issue Aug 9, 2024
@roman-yukhno-axon
Copy link
Contributor

roman-yukhno-axon commented Sep 8, 2024

@ANovokmet it works fine now (in 4.4.2). I try to set both new rows and tasks and it works without flushing it sequentally. Thanks!

gantt.$set({rows, tasks});

@leducminhthe
Copy link

i have error too, when i using gantt.removeTask(id) and set it again it error in version 4.4.2, but if i using version 4.2.4 it work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants