Hello, I am trying to update database with ajax. I'm using sql server with Entity framework. It seems that actioncomplete method doesn't work. have added actioncomplete="actionComplete" in my Gantt listing, added the actioncomplete script, but the script will never be triggered. Please, help.
This is my Gantt listing:
@using Syncfusion.EJ2.Gantt;
actionComplete="actionComplete" renderBaseline="true" toolbar="@(new List
progress="Progress" dependency="Predecessor">
allowTaskbarEditing="true" showDeleteConfirmDialog="true" mode="Auto">
This is my controller:
using Microsoft.AspNetCore.Mvc;
using Proposta.Models;
using Syncfusion.EJ2.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Proposta.Controllers
{
public class ODLGanttController : Controller
{
private readonly DataContext _context;
public ODLGanttController(DataContext context)
{
_context = context;
}
public IActionResult Index(int Id)
{
var context = new DataContext();
List
lista = _context.Ordine_Di_Lavoro.Where(o => o.IdOrdine == Id).ToList();
ViewBag.dataSource = lista;
return View();
}
[HttpPost()]
public ActionResult Add(Ordine_Di_Lavoro Task)
{
using (_context)
{
var insertData = new Ordine_Di_Lavoro()
{
TaskId = Task.TaskId,
TaskName = Task.TaskName,
StartDate = Task.StartDate,
EndDate = Task.EndDate,
Progress = Task.Progress
};
_context.Ordine_Di_Lavoro.Add(insertData);
_context.SaveChanges();
}
return Json(Task);
}
[HttpPost()]
public ActionResult Update(Ordine_Di_Lavoro Tasks)
{
using (_context)
{
var updateData = _context.Ordine_Di_Lavoro.FirstOrDefault(x => x.TaskId == Tasks.TaskId);
updateData.TaskId = Tasks.TaskId;
updateData.TaskName = Tasks.TaskName;
updateData.StartDate = Tasks.StartDate;
updateData.EndDate = Tasks.EndDate;
updateData.Progress = Tasks.Progress;
_context.SaveChanges();
}
return Json(Tasks);
}
[HttpPost()]
public ActionResult Delete(Ordine_Di_Lavoro Task)
{
using (_context)
{
var deleteData = _context.Ordine_Di_Lavoro.Single(r => r.TaskId == Task.TaskId);
_context.Ordine_Di_Lavoro.Remove(deleteData);
_context.SaveChanges();
}
return Json(Task);
}
}
}
Thank you very much, Lokesh!
I am following another way, as you can see here:
It is a very clean way to manage crud operations in Gantt ej, but I am not able to repeat this in ej2. Is it possible to have a working sample of this solution with ejs and Entity framework? I don't want to use DataManager
P.S.: your support is great!
Hi, Lokesh, thank you very much!
Good morning, Sirs,
I've finally followed your suggestions, and achieved my goal: now I'm able to fetch data from sqlserver, editing and save to database. All of these using Datamanager support. Thank you very much!
Now I have two small issue:
1) I cannot see dependency lines in my taskbar, as you can see in the attached image;
2) I cannot edit anything from taskbar, I can edit only from the grid. In practical... taskbar is readonly.
Could I riceive your precious support another time?
Thank you so much in advance!
Hi, Monisha, thank you for your kind reply!
I've tryed your solution, connecting to my URLDatasource, but the result is the same (as you can see from attached image).
Every kind of idea will be precious. I've lerned the whole Syncfusion Gantt Chart Documentation, and I've followed all the directions perfectly.
Thank you!
Hi, Monisha,
I've found that there was a Blazor tag in _Layout.cshtml that was disturbing my Gantt chart.
It was this:
<base rel='nofollow' href="~/" />
Once I get rid of this, I can see my dependency lines again, as you can see in the image here attached.
But....
Now I've lost CRUD functionallity, as the BatchSave methos never get triggered anymore.
So, if I get the lines I don't get the CRUD; If I get the CRUD I don't get the lines. Is it a bug?
I have Asp.net Core with MVC and .net 5.0
Could you suggest me something?
Thank you so much!
David