Custom task type throwing Invalid dates

Hi,

I created custom task type, and now after the task has been loaded to the screen. It throws Invalid dates error.
Is there any way for me to check where is it thrown from? I suspected it is due to this new type because when I load the rest of the tasks without loading this new type, it doesn’t throw the error.

I tried to replicate the behavior but wasn’t able to do so in here but this is the same data format that I am passing in my actual app.

One thing I noticed was that in the snippet, after printing out the task, the task with type store, it is as such.

image

But in my actual app, the output is as such:

image

The only thing i noticed are:

  1. start_date and end_date is default to 1970 if there is no children to this new type
  2. progress field is being set in mine (which I didn’t set)

Any advice?

Hello Joseph,
I suppose the issue is related to date parameters.
Each regular task should have at least 2 date parameters: start_date, end_date, duration. When a regular task doesn’t have those parameters, it should be unscheduled.
Project tasks ignore the date parameters, so they can be loaded without those parameters:
http://snippet.dhtmlx.com/dd3973ee5

However, it is possible to load regular and custom tasks without dates. In that case, the dateless tasks will obtain the date parameters from their children or from other tasks.
But that task cannot be the first one that you load:
http://snippet.dhtmlx.com/05ced85c4
http://snippet.dhtmlx.com/bc8fdfc9f
In that situation, you can assign any date in the onTaskLoading event handler. After adding children, you will be able to see the task, and after you drag or resize children, the parent task will be resized:
http://snippet.dhtmlx.com/a0e68e798

Hi @ramil,

You are right, I suspected as well, but not quite sure the exact reason that triggers it. Now that you mention it, and I quote

But that task cannot be the first one that you load:

I did load all my store type first, which is why I gotten the error.

This example (you given) is I think exactly what I want to show: https://snippet.dhtmlx.com/bc8fdfc9f

There is a problem using onTaskLoading with React at the moment, I don’t have the specific right now, but I’ll get back to you again when I have access to it (later on).

Nonetheless, the reason that I create a custom store is because I want to use it as a parent to hold all the children, you may think as a grouping. Hence, this store has no meaning or any purpose so to speak. Hence, even if I am able to use onTaskLoading, I don’t expect to init with a start_date or duration.

Project tasks ignore the date parameters, so they can be loaded without those parameters:

Can I have the ability to do so for the custom type as well? So that I can load the store without initializing any start_date, end_date, or duration. I actually had assigned a css to this custom type to display: none so that it doesn’t even show anything on the Chart.

Hello Joseph,

Nonetheless, the reason that I create a custom store is because I want to use it as a parent to hold all the children, you may think as a grouping. Hence, this store has no meaning or any purpose so to speak. Hence, even if I am able to use onTaskLoading, I don’t expect to init with a start_date or duration.

Thank you for the clarification. Unfortunately, there is no way to change how Gantt works. It assigns the date parameters to all tasks, otherwise, Gantt cannot process them.
You need to apply some modifications to make Gantt work the way you want. In some cases, you need to modify the Gantt code.


Can I have the ability to do so for the custom type as well? So that I can load the store without initializing any start_date, end_date, or duration. I actually had assigned a css to this custom type to display: none so that it doesn’t even show anything on the Chart.

I think it will be easier to add the unscheduled: true property to those tasks. Then, you won’t see those tasks in the timeline and will be able to load them without date parameters:
http://snippet.dhtmlx.com/0aeb9efd9

Hi @ramil,

Thanks, but I don’t think want to go down that path of modifying the source code.

I went to look at unscheduled-task and it does seem like what I needed. I did a quick test, and noticed this behavior, so I wanted to clarify first.

  1. By default, show_unscheduled is true, and with that, the default start_date is set to today and end_date is set to the next day.
  2. when show_unscheduled is set to false, it will be based on the children earliest start_date and latest end_date

Would there be any possible side effect because the date is set to something (by default by gantt)? Or I can safely ignore it?
show_unscheduled basically means to whether to show on chart or not right? It will always be displayed on the Grid?

Is there any difference if I don’t use unscheduled property, and just define my task as

type: 'store'
start_date: 'some_date'

and set to use css to define it to not display it as what I am doing right now.

Any pros and cons over one another?

Thanks.

Hello Joseph,

Would there be any possible side effect because the date is set to something (by default by gantt)? Or I can safely ignore it?

If it is a task that is not visible on the screen, I don’t think that you will encounter any side effects.
But if you try deleting the date properties, you will encounter issues.


show_unscheduled basically means to whether to show on chart or not right? It will always be displayed on the Grid?

Yes, that option defines if the task will be displayed in the timeline or not. If you use that option, the task will always be displayed in the grid even if you set the date range:
http://snippet.dhtmlx.com/8b36df431


Is there any difference if I don’t use unscheduled property, and just define my task as

type: 'store'
start_date: 'some_date'

and set to use css to define it to not display it as what I am doing right now.

Any pros and cons over one another?

If you load only one task without dates, you will get the error message. You will see it every time you load the data, but as Gantt fixes that issue by assigning the date, I don’t think that you will encounter issues. Maybe the issue would be that the timeline starts from the 1970 year.

And if you have a mix of unscheduled tasks and tasks without dates, you will also get the error messages:
http://snippet.dhtmlx.com/b2c3e717c
But you can still use Gantt with those errors.

If you hide the task via css and there is a link to that task, you will see a link to an empty row:

Hi @ramil,

Thanks for the clarification.

Will be back if there is any more issue with regards to this.