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

args is undefined on ActionComplete

Hi

The args is undefined on all actions. 

Used this example:

https://www.syncfusion.com/kb/5562/how-to-update-changes-from-gantt-control-to-sql-database

 <ej:Gantt ID="GanttContainer" runat="server" CssClass="gantt" DataSourceID="SqlDataSource1"
        AllowSelection="true"
        ContextMenuOpen="contextMenuOpen"
        EnableContextMenu="true"
        TaskIdMapping="TaskId"
        TaskNameMapping="TaskName"
        StartDateMapping="StartDate"
        EndDateMapping = "EndDate"
        DurationMapping="Duration"
        ProgressMapping="Progress"
        IsResponsive="true"
        BaseLineStartDate ="baselineStartDate"
        BaseLineEndDate = "baselineEndDate"
        ScheduleStartDate="02/03/2017"
        ScheduleEndDate="03/09/2017"
        ParentTaskIdMapping="ParentId"
        TreeColumnIndex="1"
        AllowDragAndDrop="True"
        AllowGanttChartEditing="true"
        Load="load"
        Height="100%"
        EnableResize="true"
        AllowSorting="true"
        AllowMultiSorting="true"
        PredecessorMapping="Predecessors" ActionComplete="actioncomplete" TaskSchedulingMode="Auto">
        <EditSettings AllowEditing="true" AllowAdding="true" AllowDeleting="true" AllowIndent="true" EditMode="cellEditing" />
        <SizeSettings Width="100%" Height="1000px" />
        
        <ToolbarSettings ShowToolbar="true" ToolbarItems="add,edit,delete,update,cancel,indent,outdent,collapseAll,expandAll,search" />
    </ej:Gantt>


    <script type = "text/javascript" >
        // To update the database through dialog editing or tool bar editing
        function actioncomplete(args) {
            var ganttRecord = args.data;
                alert(args.count);

            if (args.requestType === 'save' && args.addedRecord) {
                //Newly Added Record is obtained here , which can be updated to database

                if (args.addedRecord.parentItem)
                    ganttRecord["ParentId"] = args.addedRecord.parentItem.taskId;
                PageMethods.AddRecord(ganttRecord);

            } else if (args.requestType === 'delete') {
                var data = args.data;
                var ganttRec = data.item;
                PageMethods.DeleteRecord(ganttRec);

                if (data.hasChildRecords) {
                    deleteChildRecords(data);
                }
            }

            // To update the database during Outdent,editing,indent,predecessor update operation
            else if (args.requestType === 'outdent' || args.requestType === 'recordUpdate') {
                var ganttRec = args.data.item;
                PageMethods.UpdateRecord(ganttRec);
            }

        }

        //Delete inner level child records
        function deleteChildRecords(record) {
            var childRecords = record.childRecords,
                length = childRecords.length,
                count, currentRecord;
            for (count = 0; count < length; count++) {
                currentRecord = childRecords[count];
                PageMethods.DeleteRecord(currentRecord.item);
                if (currentRecord.hasChildRecords) {
                    deleteChildRecords(currentRecord);
                }
            }
        } 
</script>

THX
Armand

2 Replies

AD Armand De Lange April 23, 2017 12:49 PM UTC

On this linevar ganttRecord = args.data; ganttRecord is undefinedAnd updating it to this worked var ganttRecord = args._cAddedRecord.item;


JD Jayakumar Duraisamy Syncfusion Team April 24, 2017 12:23 PM UTC

Hi Armand, 
 
We regret for the inconvenience caused. 
 
We could reproduce the issue due to online documentation sample code mistake. This issue in KB will be corrected and refreshed ASAP. 
Please refer following code snippets, 
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 === 'outdent' || args.requestType === 'recordUpdate') {                 
                var ganttRec = args.data.item; 
                PageMethods.UpdateIt(ganttRec); 
            } 
 
        } 
 
We have also prepared a sample in ASP.NET to perform CRUD operation, please find a sample location below, 
Regards, 
Jayakumar D 


Loader.
Up arrow icon