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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Chart datasource custom class

Thread ID:





150893 Jan 23,2020 02:22 PM UTC Feb 26,2020 04:26 PM UTC Angular - EJ 2 3
Tags: Gantt Chart
Asked On January 23, 2020 02:22 PM UTC


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; }




Karthikeyan Raja [Syncfusion]
Replied On 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. 

Replied On 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.

Karthikeyan Raja [Syncfusion]
Replied On 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 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon