Having problems with events not triggering in Gantt.

5 posts, 0 answers
  1. mutlu
    mutlu avatar
    2 posts
    Member since:
    Nov 2015

    Posted 02 Dec 2015 Link to this post

    Hi,

    I was trying hard to use Gantt with Oracle Database over the Oracle Managed Connection, with Visual Studio 2013/ASP.NET 4.5. Well I had a few problems.

    Then I returned to the blackboard and Worked on your Example. Then I hit an end.

    So when you want resource assignments to be made, You cant. The events do not trigger. Am I missing something?

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Temp_GanttBinding_List.aspx.cs" Inherits="GanttDBConnection.Temp_GanttBinding_List" %>
     
    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI.Gantt" tagprefix="cc1" %>
     
    <!DOCTYPE html>
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <telerik:RadScriptManager runat="server"></telerik:RadScriptManager>
        <div>
     
            <telerik:RadGantt runat="server" ID="RadGantt1"
                Culture="tr-TR" LocalizationPath="LocalResources"
                SnapToGrid="false" AutoGenerateColumns="false"
                SelectedView="MonthView" EnableResources="true"
     
                OnDependencyInsert="RadGantt1_DependencyInsert"
                OnDependencyDelete="RadGantt1_DependencyDelete"
     
                OnTaskDelete="RadGantt1_TaskDelete"
                OnTaskUpdate="RadGantt1_TaskUpdate"
                OnTaskInsert="RadGantt1_TaskInsert"
                 
                OnAssignmentDelete="RadGantt1_AssignmentDelete"
                OnAssignmentInsert="RadGantt1_AssignmentInsert"
                OnAssignmentUpdate="RadGantt1_AssignmentUpdate"
                >
                <Columns>
                    <telerik:GanttBoundColumn DataField="ID" HeaderText="#" Width="40px"></telerik:GanttBoundColumn>
                    <telerik:GanttBoundColumn DataField="Title" HeaderText="Başlık" DataType="String"></telerik:GanttBoundColumn>
                    <telerik:GanttResourceColumn HeaderText="Atanmış Kaynak"></telerik:GanttResourceColumn>
                </Columns>
     
                <DataBindings>
                    <TasksDataBindings  IdField="ID"  TitleField="Title"  StartField="Start"  EndField="End"
                        PercentCompleteField="PercentComplete"  OrderIdField="OrderID"  SummaryField="Summary"  ParentIdField="ParentID" />
     
                    <DependenciesDataBindings  IdField="ID"  PredecessorIdField="PredecessorID"
                        SuccessorIdField="SuccessorID"  TypeField="Type" />
                     
                    <ResourcesDataBindings IdField="ID"
                        TextField="Name"
                        ColorField="Color" />
     
                    <AssignmentsDataBindings IdField="ID"
                        TaskIdField="TaskID"
                        ResourceIdField="ResourceID"
                        UnitsField="Units" />
                </DataBindings>
            </telerik:RadGantt>
     
        </div>
        </form>
    </body>
    </html>

     

    Then I kind of added some to simulate my own project.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
    using Telerik.Web.UI.Gantt;
    using System.Data;
     
    namespace GanttDBConnection
    {
        public partial class Temp_GanttBinding_List : System.Web.UI.Page
        {
            private const string TasksKey = "Telerik.GanttSample.Tasks";
            private const string DependenciesKey = "Telerik.GanttSample.Dependencies";
            private const string AssignmentsKey = "Telerik.GanttSample.Assignments";
            private const string ResourcesKey = "Telerik.GanttSample.Resources";
     
            private List<Task> Tasks
            {
                get
                {
                    List<Task> sessionTasks = Session[TasksKey] as List<Task>;
     
                    if (sessionTasks == null)
                    {
                        sessionTasks = new List<Task>();
     
                        sessionTasks.Add(new Task
                        {
                            ID = 1,
                            Title = "Yeni Görev",
                            Start = new DateTime(2015, 8, 5, 12, 40, 0),
                            End = new DateTime(2015, 8, 5, 12, 40, 0),
                            OrderID = 0
                        });
     
                        Session[TasksKey] = sessionTasks;
                    }
     
                    return sessionTasks;
                }
            }
     
            public List<Dependency> Dependencies
            {
                get
                {
                    List<Dependency> sessionDependencies = Session[DependenciesKey] as List<Dependency>;
     
                    if (sessionDependencies == null)
                    {
                        sessionDependencies = new List<Dependency>();
     
                        Session[DependenciesKey] = sessionDependencies;
                    }
     
                    return sessionDependencies;
                }
            }
     
            public List<CustomGanttResource> CustomGanttResources
            {
                get
                {
                    List<CustomGanttResource> sessionResources = Session[ResourcesKey] as List<CustomGanttResource>;
     
                    if (sessionResources == null)
                    {
                        sessionResources = new List<CustomGanttResource>();
     
                        sessionResources.Add(new CustomGanttResource
                        {
                            ID = 1,
                            Name = "Mutlu",
                            Color = "#ff0000"
                        });
     
                        Session[ResourcesKey] = sessionResources;
                    }
     
                    return sessionResources;
                }
            }
     
            public List<Assignment> Assignments
            {
                get
                {
                    List<Assignment> sessionAssignments = Session[AssignmentsKey] as List<Assignment>;
     
                    if (sessionAssignments == null)
                    {
                        sessionAssignments = new List<Assignment>();
     
                        Session[DependenciesKey] = sessionAssignments;
                    }
     
                    return sessionAssignments;
                }
            }
     
            protected void Page_Load(object sender, EventArgs e)
            {
                RadGantt1.DataSource = Tasks;
                RadGantt1.DependenciesDataSource = Dependencies;
                RadGantt1.ResourcesDataSource = CustomGanttResources;
                RadGantt1.AssignmentsDataSource = Assignments;
            }
     
            protected void RadGantt1_TaskDelete(object sender, TaskEventArgs e)
            {
                foreach (Task task in e.Tasks)
                {
                    var original = GetByID((int)task.ID);
     
                    Tasks.Remove(original);
                }
            }
     
            protected void RadGantt1_TaskUpdate(object sender, TaskEventArgs e)
            {
                foreach (Task task in e.Tasks)
                {
                    var original = GetByID((int)task.ID);
     
                    original.Start = task.Start;
                    original.End = task.End;
                    original.Title = task.Title;
                    original.PercentComplete = task.PercentComplete;
                    original.OrderID = task.OrderID;
                    original.Summary = task.Summary;
                    original.ParentID = task.ParentID;
                }
            }
     
            protected void RadGantt1_TaskInsert(object sender, TaskEventArgs e)
            {
                foreach (Task task in e.Tasks)
                {
                    task.ID = NextID();
     
                    Tasks.Add(task);
                }
            }
     
            private Task GetByID(int id)
            {
                return Tasks.Find((task) => (int)task.ID == id);
            }
     
            private int NextID()
            {
                var nextID = 0;
     
                foreach (ITask task in Tasks)
                {
                    if ((int)task.ID > 0)
                    {
                        nextID = (int)task.ID;
                    }
                }
     
                return ++nextID;
            }
     
            protected void RadGantt1_DependencyInsert(object sender, DependencyEventArgs e)
            {
                foreach (Dependency dependency in e.Dependencies)
                {
                    dependency.ID = NextDependencyID();
     
                    Dependencies.Add(dependency);
                }
            }
     
            protected void RadGantt1_DependencyDelete(object sender, DependencyEventArgs e)
            {
                foreach (Dependency dependency in e.Dependencies)
                {
                    var original = GetDependencyByID((int)dependency.ID);
     
                    Dependencies.Remove(original);
                }
            }
     
            private Dependency GetDependencyByID(int id)
            {
                return Dependencies.Find((dependency) => (int)dependency.ID == id);
            }
     
            private int NextDependencyID()
            {
                var nextID = 0;
     
                foreach (IDependency dependency in Dependencies)
                {
                    if ((int)dependency.ID > 0)
                    {
                        nextID = (int)dependency.ID;
                    }
                }
     
                return ++nextID;
            }
     
            protected void RadGantt1_AssignmentDelete(object sender, AssignmentEventArgs e)
            {
                //Just to see if this event triggers.
                int a = 5;
            }
     
            protected void RadGantt1_AssignmentInsert(object sender, AssignmentEventArgs e)
            {
                //Just to see if this event triggers.
                int a = 5;
            }
     
            protected void RadGantt1_AssignmentUpdate(object sender, AssignmentEventArgs e)
            {
                //Just to see if this event triggers.
                int a = 5;
            }
     
            public class CustomGanttResource
            {
                public void CustomGanttResources(int ID, string Name, string Color)
                {
                    _ID = ID;
                    _Name = Name;
                    _Color = Color;
                }
                private int _ID;
                public int ID
                {
                    get { return _ID; }
                    set { _ID = value; }
                }
                private string _Name;
                public string Name
                {
                    get { return _Name; }
                    set { _Name = value; }
                }
                private string _Color;
                public string Color
                {
                    get { return _Color; }
                    set { _Color = value; }
                }
            }
     
        }
    }

     

     

    Thanks in Advance.

    Mutlu

  2. Muhammed
    Muhammed avatar
    2 posts
    Member since:
    Dec 2015

    Posted 02 Dec 2015 Link to this post

    fa$o
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Muhammed
    Muhammed avatar
    2 posts
    Member since:
    Dec 2015

    Posted 04 Dec 2015 in reply to mutlu Link to this post

    o$ɐɟ
  5. BO
    BO avatar
    2 posts
    Member since:
    Mar 2015

    Posted 28 Feb Link to this post

    Same problem.  Assignment events are not firing (e.g. RadGantt1_AssignmentInsert)
  6. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 29 Feb Link to this post

    Hello All,

    We are aware of that problem and it is a bug, related with the RadGantt server-side event triggered. Here you can vote for the bug fix and track it's status, in addition, I have increased the bug priority.

    http://feedback.telerik.com/Project/108/Feedback/Details/175854-radgantts-server-events-for-assignments-update-insert-and-delete-are-not-trig

    On a side note, as a workaround, you can use a CustomProvider for the Gantt data population.

    Regards,

    Nencho
    Telerik
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017