I should like to update some supplementary data with task update.
In case of drag&drop everything is working:
gantt.attachEvent(“onAfterTaskDrag”, function(id, mode) {
var task = gantt.getTask(id);
var Usw = 1;
gantt.getTask(id).Update_sw = Usw;
gantt.updateTask(id);
var dudu = “”+task.duration+""
gantt.getTask(id).Publ_dur = dudu;
var Ps = task.start_date
gantt.getTask(id).Publ_start = Ps;
gantt.updateTask(id);
});
BUT in case of Lightbox the same code is wrong:
gantt.attachEvent(“onLightboxSave”, function(id,task){
var dudu = “”+task.duration+""
gantt.getTask(id).Publ_dur = dudu;
gantt.getTask(id).Update_sw = 1;
var Ps = task.start_date
gantt.getTask(id).Publ_start = Ps;
gantt.updateTask(id);
//gantt.hideLightbox();
//return true;
});
The supplementary data are updated, but the “save” button is died.
If I work with “return true”, the “save” is working, but the updates are wrong.
The “hideLightbox” also kills the saveing.
I have tried all of the events without success…
You need to have “return true;” at the end of onLightboxSave handler, or it will be blocked
gantt.attachEvent("onLightboxSave", function(id,task){
...
return true;
});
The “return true” saves data to database, refresh the gantt, but not able to refresh the grid…
It is seems to be there is something trouble with the “onLightboxSave” event.
This is my grid:
gantt.config.columns = [
{ name: “WBS”, label: “Tevékenység”, template: function(obj) {
return obj.WBS + “-” + obj.Update_sw + " " + obj.text ;
}, tree: true, width: ‘*’ },
{ name: “Publ_start”, label: “Kezdés”, template: function(obj) {
return obj.Publ_start ;
}, width: ‘70’ },
{ name: “Publ_dur”, label: “nNap”, template: function(obj) {
return obj.Publ_dur ;
}, width: ‘30’ },
{ name: “add”, label: “”, width: 30 }
];
And this my event:
gantt.attachEvent(“onLightboxSave”, function(id,task){
var dudu = “”+task.duration+""
gantt.getTask(id).Publ_dur = dudu;
gantt.getTask(id).Update_sw = 1;
var Ps = task.start_date
gantt.getTask(id).Publ_start = Ps;
gantt.updateTask(id);
return true;
});
The update in database is perfect.
But in the grid only the obj.text is updated.
This is very interesting, because the obj.text is a part of configed column. And the other parts that column are not refreshed.
If I messaged the supplemantary data, I can received the new data, but in the grid are not able to show these new data.
The drag&drop event works perfectly with all of data.
Change the code like next
[code]gantt.attachEvent(“onLightboxSave”, function(id,task){
var dudu = “”+task.duration+""
task.Publ_dur = dudu;
task.Update_sw = 1;
var Ps = task.start_date
task.Publ_start = Ps;
return true;
});
[/code]
- there is no need for updateTask call, it will be done automatically
- instead of getTask apply all changes to the task parameter. After onLightboxSave event gantt will copy all properties from the task parameter to the real task object. If you have changed that real object, such changes may be overwritten during copy from task parameter to the task object.
WOW. Great!
Everything works correctly!
Thanks!