I am trying to create a tree structure for the tasks from a flat array (since this is the way they come from the DB) by using the transformFlatData property and parentId.
However, when I am trying to map the data to the TaskModel, parentId is always set to null, even when it should have a value.
Is there something I am doing wrong? How can I set the parentId in order to create a tree structure?
Re: [REACT] ParentId on TaskModel is always null
Posted: Mon Sep 26, 2022 5:59 pm
by mats
Can you please provide us a simple test case + your data?
Thank you, this seems to work. But my remaining problem is typing. Since we are using typescript in our application, I expect the variable to be a certain type and by doing this, I cannot type it. Is there a way to do this?
And why does it work this way, but not when creating a new TaskModel (or a new Model that extends the TaskModel class in order to add new fields)?
Re: [REACT] ParentId on TaskModel is always null
Posted: Wed Sep 28, 2022 10:01 am
by johan.isaksson
Hi,
Our typings has definitions for TaskModel & TaskModelConfig, where TaskModelConfig basically contains the fields. You should be able to use it to define the block in that map() as Partial<TaskModelConfig>