Split tasks in gantt chart

I used the UrlAdaptor to give my gantt chart the tasks data, but now I want to implement the split task feature, what should I do?

1) Add the code below to e-gantt-taskfields, coz I am using self-referential data:

segmentId="segmentId" 

2) Create a ganttchart table and a ganttsegment table, where ganttsegment table is like this:

  GanttSegment Record1 = new GanttSegment()
            {
                segmentId = 2,
                Duration = 2,
                StartDate = new DateTime(2019, 04, 02),
            };

 3) Should I add a column called segmentid in my ganttchart table? How to map the ganttsegment table's records to the gantt chart, do I need to add a new UrlAdaptor, coz I saw this code, implying that the segment data is stored in another table, not the ganttchart table:

            ViewBag.DataSource = GanttData.SplitTasksData();
            ViewBag.Segment = GanttData.SegmentData();



6 Replies

SJ Sridharan Jayabalan Syncfusion Team July 16, 2024 02:23 PM UTC

Hi Desmond,

 

Greetings from Syncfusion.

 

Query 1 - Should I add a column called segmentid in my ganttchart table?

 

No. You need to add the "segmentId" into the Gantt Chart's taskfields. Refer code snippet.

 

Query 2 - How to map the ganttsegment table's records to the gantt chart, do I need to add a new UrlAdaptor, coz I saw this code, implying that the segment data is stored in another table, not the ganttchart table:

 

To set the segment data collection to Gantt Chart, you need to use segmentData property in <ejs-gantt>. It is not necessary to use Url Adaptor for binding segmentData.  Refer code snippet. This is enough to render the split tasks by using self referencial data source.

 

Code-Snippet:   

<ejs-gantt id='Gantt' dataSource="ViewBag.dataSource" segmentData="ViewBag.Segment" height="450px">


    <e-gantt-taskfields id="TaskId" name="TaskName" startDate="StartDate"

            endDate="EndDate" duration="Duration" progress="Progress" segmentId="segmentId" child="SubTasks">

    </e-gantt-taskfields>


</ejs-gantt> 

 

 

Documentation - Data Binding in Syncfusion ASP.NET CORE Gantt Component

                            - Splitting and merging task in Syncfusion ASP.NET CORE Gantt Component

 

 

Regards,

Sridharan



DE desmond July 16, 2024 03:21 PM UTC

Thanks a lot for the reply. Refering query 2, because my old code uses the UrlAdaptor to call the batchUrl function to complete CRUD operations with my remote database, and it works for years, so I wonder if I could also use the UrlAdaptor to implement the split task function. I am not sure but when using UrlAdaptor together with ViewBag.Segment, CRUD operations for the two may become hard to handle and synchronize?

If you agree with the above, is it possible to simply write a UrlAdaptor that handles both the gantt data and the segments data? With limited resources, may I get an example of how exactly the database and table models should look if I use segmentId, coz all the examples given are using segments = "Segments", where Segments is a List, with GanttSegment class objects.



SJ Sridharan Jayabalan Syncfusion Team July 17, 2024 12:58 PM UTC

Desmond,

 

After reviewing your query, currently do not have support to use remote datasource simultaneously for both Gantt data and segmentData property in Gantt functionality.

 

We have logged feature request for the requirement. You can track the status of the feature from the feedback link given below.

 

Feedback - Provide support to use remote datasource simultaneously for both Gantt data and segmentData property in ASP.NET Core | Feedback Portal (syncfusion.com)

 

We have already lined up some major features, we could not implement this support immediately. We will implement this and include it in any of our upcoming releases. Please cast your vote on this feature. Based on the customer demand we will prioritize the features in our upcoming road map. You can communicate with us or track the status of the feature using the feedback link.

 

 

And also, by using "ViewBag.segmentData" for segmentData property is not working properly and do not render the segmented tasks in UI.

 

To address the problem, we have logged a bug request, and the fix will be provided in the patch release which is scheduled to be rolled out on August 6, 2024. You can track its status from the feedback link given below.

 

Feedback - https://www.syncfusion.com/feedback/59586/split-tasks-not-working-properly-while-using-segmentdata-property

 

Note: Kindly login into your account and view the feedback.

 

Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization

 

 

Regards,

Sridharan



DE desmond July 18, 2024 03:04 PM UTC

Actually this demo https://ej2.syncfusion.com/aspnetcore/gantt/splittasks#/fluent2 doesn't use ViewBag.segmentData, it uses a List to store the segments in the Segments attribute. Do you think that it is possible to detect the segments editing events in that gantt demo, and then do CRUD operations on the gantt database? If yes, can I get a demo code, so that I can tweak it and do CRUD operations on a remote database? I hope no extra buttons have to be created if possible.



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team July 18, 2024 05:09 PM UTC

Desmond,


As per mentioned in previous response, Currently we don’t have support for this request. We will include this scenario in our feature request (for updating the segmentData property during CRUD operations for segmented records). By using this updated segmentData property, data will be sent to the server via an AJAX call for further processing. Until then we appreciate your patience.


Feedback link:- https://www.syncfusion.com/feedback/59586/split-tasks-not-working-properly-while-using-segmentdata-property


Note: The actionComplete event will be triggered for every split and merge operation on the records.


Regards,

Farveen sulthana  T



SJ Sridharan Jayabalan Syncfusion Team August 8, 2024 04:40 PM UTC

Desmond,

 

We appreciate your patience.

 

The reported issue occurred because updating segmentData property not handled and now the fix for the issue “Split tasks not working properly while using segmentData property in ASP.NET Core | Feedback Portal (syncfusion.com)” has been rolled out in our latest patch release (v26.2.8). So upgrade to our latest version to resolve the problem.

 

Release notes - Essential Studio for EJ2 TypeScript Weekly Release Release Notes (syncfusion.com)

 

The provided fix only updates the segmentData property for every CRUD action on the segmented records. The exsisting batchUpdate() has no use case for updating segmentData. So, you want to manually update the segmentData property in your database. By using actionComplete event, will give you the updated segmentData in the request types "splitTaskbar" and "mergeSegment." Using ajax(), you can send the updated segmentData values to the HomeController.cs file and update your database with those values.

Note: In the future by the feature improvement, we will include a fix to directly update the segmentData property without needing ajax().

 

Code-Snippet:   

HomeController.cs:-

 

public class SegmentData

        {

            public int SegmentId { get; set; }

            public DateTime StartDate { get; set; }

            public int Duration { get; set; }

        }

        public class SegmentViewModel

        {

            public List<SegmentData> Value { get; set; }

        }

        [HttpPost]

        public IActionResult UpdateSegment([FromBody] SegmentViewModel model)

        {

            // Now you can access model.Value which will be a list of SegmentData objects

            foreach (var item in model.Value)

            {

                int segmentId = item.SegmentId;

                DateTime startDate = item.StartDate;

                int duration = item.Duration;

            }

             //// here you will get the segmentData property's value

            return Json(new { success = true, receivedData = model });

        }

 

 

Index.cshtm:-

 

 function actionComplete(args) {

       if (args.requestType == "splitTaskbar" || args.requestType == "mergeSegment") {

           var ganttObj = document.getElementById("Gantt").ej2_instances[0].segmentData;

           var ajax = new ej.base.Ajax(

               {

                   url: 'http://localhost:5260/Home/UpdateSegment',

                   type: 'POST',

                   contentType: "application/json",

                   data: JSON.stringify({ value: ganttObj }),

               });

           ajax.send();

       }

   }

Sample -  https://www.syncfusion.com/downloads/support/directtrac/general/ze/SegmentDataCoreSample-1814937024.zip

  

 

 

 

Regards,

Sridharan


Loader.
Up arrow icon