scheduleStartDate value on model passed in to chartInstance.setModel() is set to undefined.

Hi

On first load we load our gantt chart with no data by passing empty lists to dataSource and Resources.
Once the view is loaded we make a call to the server to fetch the data so that we can populate our chart using the setModel method.

var model = fetchModelFromServer();

var chartModel = {
     dataSource: model.dataSource,
     resources: model.resources,
     scheduleStartDate: model.scheduleStartDate,
     scheduleEndDate: model.scheduleEndDate
 }

$(`#GanttChart`).ejGantt("instance").setModel(chartModel)

The first time this is done the chartModel object retains all of its values, but calls to setModel after the first leaves chartModel.scheduleStartDate as undefined

3 Replies

KR Karthikeyan Raja Syncfusion Team February 26, 2020 01:05 PM UTC

Hi Martin, 
 
We have analyzed your query. We suspected that your reported issue may due to chartModel.scheduleStartDate is not retrieved from server side. So kindly ensure whether you have retrieved it. We are usually making ajax call to server and on ajax success call we get the returned data. So we suggest you  to use same. 
Please find the code snippet below, 
[controller.cs] 
//…… 
 
public object getDatasource() { 
  return Json(new { //…..  start = scheduleStart,}); 
} 
 
[index.cshtml] 
$("#ganttContainer").ejGantt({ 
           //…. 
}); 
$("#update").ejButton({ "click": "onClick", width: "100" }); 
}); 
function onClick(args) { 
   $.ajax({ 
       type: "POST", 
       url: "/Home/getDatasource", 
       dataType: "json", 
       success: function (result) { 
            var model = ej.parseJSON(result); 
            var chartModel = { 
                //….                 
               scheduleStartDate: model.start, 
            }; 
            var ganttObj = $("#ganttContainer").data("ejGantt"); 
            ganttObj.setModel(chartModel); 
       } 
   }); 
} 
 
We have prepared sample with your requirement. Please find the sample from below link 
 
If you are still facing issue, Please revert us with issue reproducable sample or video so it will be very helpful for serve you better. 
  
Regards, 
Karthikeyan Raja 



MM Martin McSharry February 26, 2020 03:35 PM UTC

Hi karthikeyan

I've modified the index.cshtml file so that the bug is reproduced.
I've added 4 console.log() statements to the end of the onClick method.
The first time you click the button the model retains its values after the ganttObj.setModel(chartModel) call
but very time you click the button after the first, the chartModel.scheduleStartDate and chartModel.scheduleEndDate are undefined

Attachment: Index_95861a8f.zip


KR Karthikeyan Raja Syncfusion Team February 27, 2020 12:45 PM UTC

Hi Martin,  
   
We have analyzed your query and able to reproduce the reported scenario. By default Gantt’s schedule start and end dates are validated based on task’s start and end dates. So there is no need to update it dynamically. Then Gantt do not validate setModel for scheduleStartDate and scheduleEndDate, So chartModel have the same value each time. Hence same value was removed from it and set as undefined.  
   
Please get back to us, if you need any further assistance on this.  
 
Regards, 
Karthikeyan Raja 
 


Loader.
Up arrow icon