Using Guid as Id (instead of int) for task in Gantt chart

1. Tasks in Gantt chart uses integer as Identifier to identify tasks uniquely. How to use Guid as task identifier instead of int?

2. Suppose it is not possible to achieve item 1 as mentioned above then I would like to seek your help in following scenario :
I have property of type Guid added Id (apart from TaskId property which is integer) in my Task viewmodel (view model class given below). When I create the new child task using the context menu (also applicable to when task created above or below selected task using context menu), it recreates new task with exact same value as selected task. In this case, TaskId property value which is integer gets incremented however GUID property still holds the same property value from previous task. Is there any way to assign the new GUID value to GUID property when new child task gets created?

public class TaskVM
    {
        public Guid ProjectId { get; set; }

        public Guid Id { get; set; }

        public int TaskId { get; set; }

        public Guid? ParentTaskId { get; set; }

        [JsonProperty("Name")]
        public string TaskName { get; set; }

        public DateTime StartDate { get; set; }

        public DateTime? EndDate { get; set; }

        public int Type { get; set; }

        public int Duration { get; set; }

        public int Progress { get; set; }

        [JsonProperty("Note")]
        public string Notes { get; set; }

        public string Predecessor { get; set; }
    }

I tried playing around with actionBegin and actionCompleted to inject new guid value but it has not helped.

Looking forward to resolve this at the earliest.

2 Replies 1 reply marked as answer

MS Monisha Sivanthilingam Syncfusion Team March 15, 2021 12:57 PM UTC

Hi Krunal, 
 
We are currently validating your query. We will provide you with a solution within one business day(16-03-2021). 
 
We appreciate your patience until then. 
 
Regards, 
Monisha. 



MS Monisha Sivanthilingam Syncfusion Team March 15, 2021 03:37 PM UTC

Hi Krunal, 
 
Thank you for contacting Syncfusion support. 
 
We have analyzed your query and have made use of the beforeOpenAddDialog and beforeAdd requestTypes in the actionBegin event to achieve your requirement. The following code snippets demonstrate the solution. 
 
Index.cshtml 
<script> 
    function actionBegin(args) { 
        var ganttObj = document.getElementById("Gantt").ej2_instances[0]; 
        if (args.requestType == "beforeOpenAddDialog") { 
            args.rowData.GUID = NewGuid(); 
        } else if (args.requestType == "beforeAdd" && ganttObj.contextMenuModule.isOpen) { 
            args.data.GUID = args.data.taskData.GUID = NewGuid(); 
        } 
    } 
    function NewGuid() { 
        function S4() { 
            return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); 
        } 
        guid = (S4() + S4() + "-" + S4() + "-4" + S4().substr(0, 3) + "-" + S4() + "-" + S4() + S4() + S4()).toLowerCase(); 
        return guid; 
    } 
</script> 
 
We have also prepared a sample for your reference. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 


Marked as answer
Loader.
Up arrow icon