function ActionComplete(args) {
debugger;
//alert("here " + args.requestType +" Add? " + args._cAddedRecord +" :: Mod?" + args._cModifiedData);
var ganttRecord = args.data;
if (args.requestType === 'save' || args._cAddedRecord) {
//Newly Added Record is obtained here , which can be updated to database
if (args._cAddedRecord.parentItem)
ganttRecord["ParentId"] = args._cAddedRecord.parentItem.taskId;
$.ajax({
type: "POST",
url: "/Plan/Add",//Add is Server side method
data: ganttRecord,
dataType: "json"
});
} else if (args.requestType === 'save' && args._cModifiedData) {
//Edited Record is obtained here , which can be updated to database
if (args._cModifiedData.parentItem)
ganttRecord["ParentId"] = args._cModifiedData.parentItem.taskId;
ganttRecord["Predecessor"] = args._cModifiedData.item.Predecessor;
$.ajax({
type: "POST",
url: "/Plan/Update", //Update is Server side method
data: ganttRecord,
dataType: "json"
});
} else if (args.requestType === 'delete') {
var ganttRec = args.data.item;
$.ajax({
type: "POST",
url: "/Plan/Delete", //Update is Server side method
data: ganttRec,
dataType: "json"
});
if (data.hasChildRecords) {
deleteChildRecords(data);
}
}
// To update the database during Outdent,editing,indent,predecessor update operation
else if (args.requestType === 'outdent' || args.requestType === 'recordUpdate') {
//alert("3");
var ganttRec = args.data.item;
$.ajax({
type: "POST",
url: "/Plan/Update", //Update is Server side method
data: ganttRec,
dataType: "json"
});
}
}
Hi Pankaj,
For your kind information.
Query 1: When I press "Save" button in the Add Task dialog, the ActionComplete event is fired twice.
Solution: We are not able to reproduce the reported issue while adding a task. ActionComplete will fire for multiple times while we adding a new task, is because while we adding a new task we have to update its depended task if there is any date changes. But args.requestType==”save” will fire only once and that time we can get the args._cAddeRecord with the newly entered details. Please ensure that you are using updated script from our dashboard. If you still facing any issue please revert to us by modifying the attached sample along with replication the replication procedure.
Query 2: Subsequently the ActionComplete is fired again with requestType being "save". However, this time, the args._cAddedRecord has only null values.
Solution: We are not able to reproduce the issue with args.requestType ==”save” and we are getting the appropriate new record details in the args._cAddedRecord. We have also analyzed your code provided in your last update and came to know that there is some code missing to add a new record to database. Please refer the below code snippet for details.
function ActionComplete(args) {
//alert("here " + args.requestType +" Add? " + args._cAddedRecord +" :: Mod?" + args._cModifiedData);
if (args.requestType === 'save' || args._cAddedRecord) { debugger; //Newly Added Record is obtained here , which can be updated to database var ganttRecord = args._cAddedRecord.item; if (args._cAddedRecord.parentItem)
ganttRecord["ParentId"] = args._cAddedRecord.parentItem.taskId;
$.ajax({
type: "POST",
url: "/Plan/Add",//Add is Server side method
data: ganttRecord,
dataType: "json"
}); } } |
We have also prepared a sample based on this and you can find the sample under the following location.
Sample: https://www.syncfusion.com/downloads/support/forum/119415/ze/MVC5Gantt1507325683
Please let us know if you need further assistance on this.
Regards,
Mahalakshmi K.
Hi Pankaj,
Sorry for the inconvenience caused.
For your kind information, the args.requestType==”recordUpdate” will fire for the each number of parents that particular affected task contains. For example if we add a new task, which is having 3 parent tasks as like in the below screen shot,
In this case if we select “child task 1” and press add button and save the task, actionComplete will fired for 6 times is to perform the different actions as like in the below table.
Event | Request type | Number of calls | Purpose |
ActionComplete | args.requestType==”refresh” | 1 | to refresh the Gantt to update the view for new item added, |
args.requestType==”recordUpdate” | 4 | to update its immediate parent items for the changes, and to update the same item for any predecessor changes. | |
args.requestType==”save” | 1 | For this specific argument type alone, the args._cAddedRecord argument will be generated with the newly added task details. The remaining event trigger this argument will not be available |
Same as while we editing also args.requestType==”recordUpdate” will fired for the number of parents it contains. And at the time of args.requestType==”save” it will get the args._cModifiedRecord with the modified details.
We would also like to inform you that we have also logged feature report on to “Optimizing client side events in Gantt” for implementing single batch update for various triggered events in near future. It will be available in any our upcoming main release.
Regards,
Mahalakshmi K.
Hi Pankaj,
Sorry for the inconveniance caused.
We can also reproduce the reported scenario. While we add a new record, in the case you reported, first requestType will be “argrs.requestType==recordUpdate” and the second call is for “argrs.requestType==save” in client side, but we pass the request through the ajax post, in the server side the process is reversed where the Add() method is called priorly to the Update() method when adding a new record , and it will not create any problem while we adding a record to the SQL server database. But still we are analysing on why the args.requestType==”recordUpate” triggers prior to the args.requestType==”save” in the client side for ActionComplete event. We will let you know the status in one business day(24/06/2015).
Regards,
Mahalakshmi K.