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
close icon

how to control the startdate and enddate on add new task on Gantt control

Hello,

How to control the startdate and enddate on add new task on Gantt control?

I cannot find a server event on Gantt control to allow me to grab the StartDate/EndDate textbox from code behind.

Thank you

3 Replies

MK Mahalakshmi Karthikeyan Syncfusion Team November 5, 2015 06:30 PM UTC

Hi Dwayne,

We can control the start Date and End date while adding a new task and set the date returned from code behind using ActionComplete client side event. Please find the code example for details.

<ej:Gantt ID="Gantt" runat="server"

ActionComplete="ActionComplete">

<AddDialogFields>

              <ej:AddDialogField Field="Id" />

              <ej:AddDialogField Field="Name" />

              <ej:AddDialogField Field="PercentDont" />

          </AddDialogFields>

</ej:Gantt>  

function ActionComplete(args) {

                var ganttObj = $("#Gantt").data("ejGantt");


                if (args.requestType === 'save' && args.addedRecord) {

var ganttRecord = args.addedRecord.item;

                    if (args.addedRecord.parentItem)

                        ganttRecord["ParentId"] = args.addedRecord.parentItem.taskId;


                    $.ajax({

                        type: "POST",

                        url: "GanttSample.aspx/getDate",

                        contentType: "application/json; charset=utf-8",

                        dataType: "json",

                        success: function (result) {

                            ganttRecord.StartDate = result.d.startdate;

                            ganttRecord.EndDate = result.d.enddate;

                            PageMethods.AddIt(ganttRecord);

                            var obj = $("#Gantt").data("ejGantt");

                            obj.reRenderChart();

                        },

                        failure: function (response) {

                            alert(response.d);

                        }

                    })                 

                }

}


public class date

        {

            public string startdate { get; set; }

            public string enddate { get; set; }

        }


        [WebMethod]

        public static date getDate()

        {

            date gantt = new date();

            gantt.startdate = "02/27/2014";

            gantt.enddate = "02/29/2014";

            return gantt;

        }

We have also prepared a sample based on this and you can find the sample under the following location.

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/DateChange245361608

Regards,

Mahalakshmi K.



DB Dwayne Boykin November 5, 2015 08:17 PM UTC

Thanks for your response.
 
Can you pre-populate the State/End date before save the task?
 
Your sample code is populate Start/End date while saving the task.
 
Thank you


MK Mahalakshmi Karthikeyan Syncfusion Team November 6, 2015 12:12 PM UTC

Hi Dwayne,
At present there is no support to change the date at pre load time from server. Hence have logged usability feature regarding this. A support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
Please let us know if you require further assistance on this.    
Regards,
Mahalakshmi K.

Loader.
Live Chat Icon For mobile
Up arrow icon