<script type="text/javascript">
function ActionComplete(args) {
var myGantt = args.data;
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);
}
}
//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>
else if (args.requestType === 'delete') {
var data = args.data;
var ganttRec = data.item;
PageMethods.DeleteIt(ganttRec);
if (data.hasChildRecords) {
deleteChildRecords(data);
}
}
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); // Rename it as DeleteIt
if (currentRecord.hasChildRecords) {
deleteChildRecords(currentRecord);
}
}
} |