2

I am using Dhtmlx Gantt to make the Gantt chart in my project. IN the tasks table I have the usual autoincremental Id. Whenever I save a task it gets the Id automatically, (this id is not the same as the source Id that is provided by the gantt chart plugin). The problem is when I try to create a link between a task and another task that is created on the fly(without refreshing the page), because the targetId of the Link object comes same as the SourceId and not the actual Id of the task in my table in db. Anyone have an Idea how to fix this?

Thanx in advance

user2622220
  • 185
  • 1
  • 5
  • 19

1 Answers1

1

I fixed it by changing my GanttResponse function into this:

 private ContentResult GanttRespose(List<GanttRequest> ganttDataCollection)
    {
        var actions = new List<XElement>();
        foreach (var ganttData in ganttDataCollection)
        {
            var action = new XElement("action");
            action.SetAttributeValue("type", ganttData.Action.ToString().ToLower());
            action.SetAttributeValue("sid", ganttData.SourceId);
            action.SetAttributeValue("tid", (ganttData.Action != GanttAction.Inserted) ? ganttData.SourceId :
                (ganttData.Mode == GanttMode.Tasks) ? ganttData.UpdatedTask.Id : ganttData.UpdatedLink.Id);
            actions.Add(action);
        }

        var data = new XDocument(new XElement("data", actions));
        data.Declaration = new XDeclaration("1.0", "utf-8", "true");
        return Content(data.ToString(), "text/xml");
    }
user2622220
  • 185
  • 1
  • 5
  • 19