Count of tasks to be updated

Hello there,

Is there a way to get the count of all the tasks that are about to be updated? My goal is to build a custom loading bar for my users to show that x amount of tasks are still saving.

Like if I move a task that is linked to 50 more tasks, is there way to get a count of all the effected tasks?

Thanks!

Hi,
it’s possible, but can be implemented in many ways, depending on how you configure data saving.
If you have the same configuration as shown in this example docs.dhtmlx.com/gantt/samples/0 … _json.html
then you can get a list of updated events in onBeforeDataSending event of the dataprocessor - screencast.com/t/VjDJGRjE - note the third argument.
docs.dhtmlx.com/api__dataproces … event.html

Also please note that for some actions (such as deleting branch of tasks) this event will be called twice - once to send tasks and once to send links.
you can check which is being sent by checking dataProcessor.serverProcessor property -

dp.attachEvent("onBeforeDataSending", function(id, state, data){ if(dp.serverProcessor.indexOf("gantt_mode=links") > -1){ //sending links }else{ //sending tasks } return true; });

In case you have dataprocessor configured differently, e.g. in REST mode, each update will be sent individually and you won’t be able to capture a single event containing all records. Instead, you could capture updating of each entry individually docs.dhtmlx.com/api__dataproces … event.html - a record is being saved after onBeforeUpdate fired and until onAfterUpdate fired - so you can capture these events and keep the list of records that are being updated now.

Thanks for the reply! I’m actually using the REST method, so i’ll have to stir something up using the two events you provided me with.

Do you know - is it possible to tell the difference between a ‘Task’ and a ‘Link’ in onAfterUpdate? I’m hoping it is stored in the response somewhere. I just want to use some more custom code if it’s a task. If it’s updating a link I want to do nothing.

Does that make sense?

Yes, although the approach with checking dataProcessor.serverProcessor url doesn’t seem to be reliable. So currently you’ll need to check an internal property of data processor object for this.
Something like following:

[code]function getUpdateMode(){
return dp._ganttMode;
}

dp.attachEvent(“onBeforeUpdate”, function(id, state, data){
if(updateMode() == “tasks”){
// do something when start updating task
}
return true;
});

dp.attachEvent(“onAfterUpdate”, function(id, state, data){
if(updateMode() == “tasks”){
// do something after task update has been completed
}
});[/code]