[HomeController.cs]
public ActionResult BatchSave([FromBody]ICRUDModel<TreeGridProjectData> data)
{
//...
if (data.added != null && data.added.Count() > 0)
{
foreach (var rec in data.added)
{
uAdded.Add(this.Create(rec));
}
}
////Performing update operation
if (data.changed != null && data.changed.Count() > 0)
{
foreach (var rec in data.changed)
{
uChanged.Add(this.Edit(rec));
}
}
//Performing delete operation
if (data.deleted != null && data.deleted.Count() > 0)
{
foreach (var rec in data.deleted)
{
uDeleted.Add(this.Delete(rec.taskID));
}
}
return Json(new { addedRecords = uAdded, changedRecords = uChanged, deletedRecords = uDeleted});
}
public TreeGridProjectData Create(TreeGridProjectData value)
{
//...
}
public TreeGridProjectData Edit(TreeGridProjectData value)
{
//...
}
public TreeGridProjectData Delete(string value)
{
//...
}
[index.cshtml]
@(Html.EJS().Gantt("DefaultFunctionalities")
.DataSource(dataManager => { dataManager.Url("/Home/UrlDatasource")
.BatchUrl("/Home/BatchSave")
.Adaptor("UrlAdaptor"); })
//...
.Render()
) |