TimeLine Bar Start & End Dynamically changed

How can I dynamically change what database field is used for the start and end of my bars in the timeline.

ie: I want the start of the bar to use the field “ScheduledDate” and the end of the bar to use the field “EstimatedCompleteDate” whenever the TASK is incomplete. If the TASK is complete determined by CompletionDate!=“0000-00-00” then I want the start of the bar to use the field “StartDate” and the end of the bar to use the field “CompletionDate”.

So how do I implement this dynamic change in the scheduler when it loads?

Hello,

Do you want to do it on server side or your task status could change in client side as well?

Best regards,
Ilya

Server side would be OK in this case as once the Task is completed in can not be changed. However I would also like to know how to do this client side for other scenarios.

If you are using connector on server side, you can add logic through beforeRender event

function set_start_date($data){
    if ($data->get_value("CompletionDate") !="0000-00-00")
         $data->set_value("ScheduledDate", $data->get_value("StartDate"));
}
$scheduler->event->attach("beforeRender", "set_start_date");
$scheduler->render_table("events","id","ScheduledDate,EstimatedCompleteDate,text,StartDate");

Hello,

And for client side you can attach handler to onEventChanged event and then check its status. If needed - change it start_date and end_date values with CompletionDate/ScheduledDate.

Best regards,
Ilya

Although your solution works it does not quite accomplish what I need now that I have changed my requirement. I now want the ability to drag the start and end of a completed task and have that saved in the database.

With your solution we have simply replaced the ScheduleDate value with the StartDate value and replaced the EstimatedCompleteDate value with the CompletionDate value. If I now drag the Bar end date this of course changes the EstimatedCompleDate value in the database. I instead need this to change CompletionDate in the database.

So I essentially need to dynamically change the mapping of the start and end of the Bar to the appropriate fields based on whether the task is incomplete or complete.

Hello,

Why of course? You can implement same logic on server side and use end_date to change ScheduleDate field in database.

Best regards,
Ilya

Can you explain how the BAR start_date and the end_date are mapped to the fields. It appears that it simply uses the first 2 date fields it finds in the render_sql Select command.

Hello,

You are absolutely correct. First 3 fields in render_table/render_sql would be start_date, end_date and text on client-side. That’s a requirement of Scheduler when working with connectors.

Best regards,
Ilya

OK if that is the case how would I dynamically change the field assignment of the sql statement. Can you have multiple render_sql commands - One for the incomplete tasks and one for the complete tasks. I tried creating 2 render_sql statements but it did not work.

My current render_sql statement is as follows:

$scheduler->render_sql(“Select * from task’”, “TID”, “SchedDate,ProjectionDate,Name,Assignto,Task,TNotes,TID,StartDate,CompleteDate,Reference,Project”)

Hello,

You can load data from simple array as well.
So what can be done in this case - you make two queries, get two result sets, then combine everything into single array.
Check more information in our documentation - docs.dhtmlx.com/doku.php?id=dhtm … _php_array

Best regards,
Ilya