Show cool things you have done with our products


Post by dhrubo »

Hi,

I've a task template and according which i'm creating the task through the addSubtask(), but i can't add dependency of that task.

How can i add a dependency when i'm creating a task through addSubtask().

Please help me in that issue.

Thanks
Dhrubo

Post by mats »

Please give us a test case, or we cannot help you.

Post by dhrubo »

Suppose i've created a task through subtask.
test = task.addSubtask(new gantt.taskStore.model({
                                                Name        : key.task_name,
                                                leaf        : true,
                                                PercentDone : 0,
                                                StartDate   :  finish_dates[key.predecessor].enddate,
                                                //FinishDate  :  date.getDate() + parseInt(key.duration),
                                                Duration    :  key.duration 
                                            //addSuccessor   :  dependency 
                                            })

i need to add dependency of that task.

Is this clear ?

Thanks
Dhrubo

Post by arcady »

Just use dependency store:
    dependencyStore.add(new dependencyStore.model({
        fromTask    : fromId, // from task Id
        toTask      : toId // to task Id
    }));

Post by dhrubo »

hi,

Thanks for your code.

I've added that block of code after creating subtask.

Now problem is that, dependency is showing that time(when i press zoom to fit), but not storing to the database, as a result, when i refresh the script, then dependency is not showing.

But if i put an alert after the addSubtask, then dependency is storing in the database.

Do you have any idea about that?

Again Thanks
Dhrubo

Post by arcady »

As Mats noted before we need a proper runnable test case to assist you. Otherwise it's hard to say something. :)

Post by dhrubo »

Hi,

Sorry for the late response.

I figured out that problem and solved.

Now i'm facing another problem.

here is my code scenario:
test = task.addSubtask(new gantt.taskStore.model({
                                                Name        : key.task_name,
                                                leaf        : true,
                                                PercentDone : 0,
                                                StartDate   :  finish_dates[key.predecessor].enddate,
                                                //FinishDate  :  date.getDate() + parseInt(key.duration),
                                                Duration    :  key.duration 
                                            //addSuccessor   :  dependency 
                                            })
i've added a subtask here. How can i get the id of the task?

I've tried with 'test.data.index' but this is not giving me the corresponding id all the time.

Please help me.

Thanks
Dhrubo

Post by mats »

test.get('Id') gives you the Id. Though for a new task, there is not yet an Id (only a "Phantom" Id) since you haven't yet saved it in your database...

Post by dhrubo »

Hi,

Thanks for your prompt answer.

i've written down this line like this:
test = task.addSubtask(new gantt.taskStore.model({
                                                Name        : key.task_name,
                                                leaf        : true,
                                                PercentDone : 0,
                                                StartDate   :  finish_dates[key.predecessor].enddate,
                                                //FinishDate  :  date.getDate() + parseInt(key.duration),
                                                Duration    :  key.duration 
                                            //addSuccessor   :  dependency 
                                            })
                                                    
                                            );
                                            alert(test.get("Id"));
But the alert is showing my 'undefined'. Do you know why?

Waiting for your kind response.

thanks
dhrubo

Post by mats »

Didn't you read my response? :)

If you want a temp id, use 'task.id'.

Post Reply