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

Example code for latest version to add, edit and delete to sql database

Thread ID:

Created:

Updated:

Platform:

Replies:

130122 Apr 23,2017 05:34 PM Apr 24,2017 08:26 AM ASP.NET Web Forms 1
loading
Tags: Gantt
Armand De Lange
Asked On April 23, 2017 05:34 PM

HI

Can you please supply me with code for the latest version of Gantt to add, edit and delete tasks as all the sample code available seems to be for older versions and not working on the latest version (15.1460.0.41)

THX
Armand

Jayakumar Duraisamy [Syncfusion]
Replied On April 24, 2017 08:26 AM

Hi Armand, 
 
Thanks for contacting Syncfusion support. 
 
We have prepared a Gantt sample to perform add, edit and delete actions with SQL database. It can be achieved by using “ActionComplete” client side event, we will get the updated data as argument and pass the data to the “pageMethod” for perform add, edit & delete operation with SQL table. 
 
Please refer following code snippet, 
<ej:Gantt ID="container" runat="server" 
//… 
ActionComplete="ActionComplete"> </ej:Gantt> 
 
<asp:ScriptManager runat="server" EnablePageMethods="true"></asp:ScriptManager> 
<script type="text/javascript"> 
        function ActionComplete(args) {             
 
            if (args.requestType === 'save' && args.addedRecord) { 
                //Newly Added Record is obtained here , which can be updated to database 
                var ganttRecord = args.addedRecord; 
                if (args.addedRecord.parentItem) 
                    ganttRecord["ParentId"] = ganttRecord.parentItem.taskId; 
 
                PageMethods.AddIt(ganttRecord.item); 
            } else if (args.requestType === 'delete') { 
                var data = args.data; 
                var ganttRec = data.item; 
                PageMethods.DeleteIt(ganttRec); 
 
                if (data.hasChildRecords) { 
                    deleteChildRecords(data); 
                } 
            } 
 
                // To update the database during Outdent,editing,indent,predecessor update operation 
            else if (args.requestType === 'recordUpdate') {                 
                var ganttRec = args.data.item; 
                PageMethods.UpdateIt(ganttRec); 
            } 
 
        } 
[ASPX.cs] 
[WebMethod] 
        public static void AddIt(TaskData record) 
        { 
            Gantt obj = new Gantt(); 
            obj.Add(record); 
        } 
        [WebMethod] 
        public static void UpdateIt(TaskData record) 
        { 
            Gantt obj = new Gantt(); 
            obj.Update(record); 
        } 
        [WebMethod] 
        public static int DeleteIt(TaskData record) 
        { 
            Gantt obj = new Gantt(); 
            obj.Delete(record); 
            return 0; 
        } 
 
We have also prepared a sample using latest version source & dll's for your reference, please find the sample location as below. 
Regards, 
Jayakumar D. 


CONFIRMATION

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.

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.

;