Possible bug when setting duration in code

Hi there,

I have a situation that I think might be due to a bug. I try to change the duration using javascript, and nothing really happens.

To exclude my own code, follow along using one of your own exemple gantts:
http://docs.dhtmlx.com/gantt/samples/01_initialization/04_connector_json.html

1. Find the task id of one of tasks (doesn’t really matter which one), using

gantt.eachTask(function(task){console.log(task);})

(In my example below I pick id 5.)

2. Check what the duration currently is

gantt.getTask(5).duration

outputs 4.

3. Change the duration to something else

gantt.getTask(5).duration = 10

4. Just to verify things are kind of working, also change the title

gantt.getTask(5).text = "LOLCAT"

5. And update the task, which causes a POST to the server

gantt.updateTask(5)

6. Look at the posted data

5_id=5&5_start_date=2013-04-05%2000%3A00%3A00&5_duration=4&5_text=LOLCAT&5_progress=0.34&5_parent=2&5_open=1&5_end_date=2013-04-09%2000%3A00%3A00&5_!nativeeditor_status=updated&ids=5

…where the relevant info is

5_duration=4 5_text=LOLCAT

Is this a known bug? Am I missing something obvious? Any possible workarounds? (Obviously I need to code the duration for this use-case so using the lightbox isn’t really an option.)

Thanks,
Fred S

PS. It might be valuable to note that if I update the duration using the lightbox, everything works as expected.

Hi,
try setting the end_date with the duration:[code]var task = gantt.getTask(5);
task.duration = 10;
task.end_date = gantt.calculateEndDate(task.start_date, task.duration);

gantt.updateTask(task.id);
[/code]
we’ll investigate why simple changing of the duration gets overwriten by an end_date. Maybe there is a reason for this behavior, otherwise we’ll fix it in the upcoming version

Thank you, I will try this work-around.

Best,
Fred S

Hi,

Just a quick note to let you know your solution worked like a charm.

Thanks,
Fred S