How can i save tasks in dhtmlx gantt?

风流意气都作罢 提交于 2019-12-13 04:49:19

问题


I used dhtmlx for chart gantt, I succeed in saving tasks in the data base, the problem is that when I add a new task there is no change in the chart, for example if I add a new task with 4 days as duration it appears just one cell not four ones and also for the other properties.

Here the code of adding a new task :

 <script type="text/javascript">

    gantt.init("gantt_here");   
    gantt.attachEvent("onLightboxSave", function(id, task, is_new){
    mnth = ("0" + (task.start_date.getMonth()+1)).slice(-2),
    day  = ("0" + task.start_date.getDate()).slice(-2);
    mnth = ("0" + (task.end_date.getMonth()+1)).slice(-2),
    day  = ("0" + task.end_date.getDate()).slice(-2);

   $.post("Control",{id:task.id,duration:task.duration,text:task.text,start_date:[ day,mnth,  task.start_date.getFullYear() ].join("-").toString()},function(data){

  alert(data);

  }) ;

 gantt.hideLightbox();
   });

</script>

回答1:


Try returning 'true' from onLightboxSave handler http://docs.dhtmlx.com/gantt/api__gantt_onlightboxsave_event.html

If you return 'false' or 'undefined' (as in your case), the form stays opened and the form values are not applied to the client-side.

Returning 'true' will save values and close the form, so you won't need to call hideLightbox manually

gantt.attachEvent("onLightboxSave", function(id, task, is_new){
   var dateToStr = gantt.date.date_to_str("%d-%m-%Y");

   $.post("Control",{
      id:task.id,
      duration:task.duration,
      text:task.text,
      start_date:dateToStr(task.start_date)
   },function(data){
      alert(data);
   }) ;

   return true;
});


来源:https://stackoverflow.com/questions/29438891/how-can-i-save-tasks-in-dhtmlx-gantt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!