[cshtml]
@(Html.EJ().Gantt("Gantt").
TaskIdMapping("TaskId").
ClientSideEvents(eve =>
{
eve.ActionComplete("actionComplete");
eve.RowDragStop("rowDragStop");
}).
)
@(Html.EJ().ScriptManager())
<script type="text/javascript">
function rowDragStop(args) {
//To update the database on drop action
var cloneData = $.extend ({}, args.draggedRow.item);
cloneData = args.draggedRow.item;
cloneData[args.model.parentTaskIdMapping] = args.targetRow.item[args.model.taskIdMapping];
var data = cloneData;
$.ajax({
type: "POST",
url: '/Gantt/Update',
data: data,
dataType: "json",
});
};
function actionComplete(args) {
//To update on indent,outdent and taskbar editing action
if (args.requestType == "indent" || args.requestType == "outdent" || args.requestType == "recordUpdate") {
var data = args.data.item;
$.ajax({
type: "POST",
url: '/Gantt/Update',
data: data,
dataType: "json",
})
}
//To update the database while adding new record
if (args.requestType == "save" && args.addedRecord) {
var data = args.addedRecord.item;
$.ajax({
type: "POST",
url: '/Gantt/Add',
data: data,
dataType: "json",
});
}
//To update the database on delete action
if (args.requestType == "delete") {
var data = args.data.item;
$.ajax({
type: "POST",
url: '/Gantt/Delete',
data: data,
dataType: "json",
});
if (args.data.hasChildRecords) {
deleteChildRecords(args.data);
}
}
}
//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];
var data = currentRecord.item;
$.ajax({
type: "POST",
url: '/Gantt/Delete',
data: data,
dataType: "json",
});
if (currentRecord.hasChildRecords) {
deleteChildRecords(currentRecord);
}
}
}
</script> |
<script type="text/javascript">
function actionBegin(args) {
if (args.requestType == "openAddDialog") {
// to cancel the default add popup
args.cancel = true;
$("#basicDialog").ejDialog({
// we can customize the pop here
});
}
}
</script> |