We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Chart datasource custom class


Using: angular 9, nswag generated typescript api client. Server-side .net core.

I have an issue using the Gantt chart in combination with nswag.

When we get the datasource data from the server (via nswag client) the items are of type GantDataSource, which has some additional methods ( “toJSON()” this method is used when serializing the data before sending to the web api. )

Saving data to the server works fine when no new items are added / manipulated.  When we add a new task item to the chart the new task is added to the datasource as a js object (without the toJSON() method.)

Manipulating the items in the grid also converts the bound GanttDataSource object(s) to a normal js objects.

Is it possible to override the type generated in the “Add” button?


Nswag: https://github.com/RicoSuter/NSwag

Our server-side model:

  public class GanttDataSource
        public int TaskId { get; set; }
        public string TaskName { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public DateTime? BaselineStartDate { get; set; }
        public DateTime? BaselineEndDate { get; set; }
        public string Duration { get; set; }
        public int Progress { get; set; }
        public string Predecessor { get; set; }
        public List<GanttDataSource> SubTasks { get; set; }
        public List<IndicatorsModel> Indicators { get; set; }
        public int[] ResourceId { get; set; }




3 Replies

KR Karthikeyan Raja Syncfusion Team January 24, 2020 12:58 PM UTC

Hi Marius, 
In Gantt, When we add a new data then data source have only fields which are mapped to the Gantt. Hence, ensure that whether you have mapped all your ”GanttDataSource” to Gantt. Moreover, You can use JSON.stringfy() to serialize the data before passing to the server. 
Please let us know, if you need further assistance on this. 
Karthikeyan Raja. 

MN MN February 25, 2020 09:17 AM UTC

sorry late reply..
JSON.stringfy() gives a core.js:3866 ERROR Error: Uncaught (in promise): TypeError: item.toJSON is not a function.

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

Hi Marius, 
We regret the inconvenience caused. 
Please use JSON.stringify() to serialize the data before passing to the server.  
If you are still facing issue, Please revert us with your code snippet or sample, It will be very useful for us to serve you better. 
Karthikeyan Raja 

Live Chat Icon For mobile
Up arrow icon