This is a migrated thread and some comments may be shown as answers.

Event OnTaskDeleted not fired unless there is only one task

1 Answer 48 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
Hugo
Top achievements
Rank 1
Hugo asked on 01 May 2017, 03:01 PM

I'm evaluating the RadGantt control for an eventual purshase. I have been able to insert and update tasks but there is a problem with deleting a task. The event OnTaskDelete is not fired unless there is only one task left or I have clicked delete on all tasks. So, if I click to delete only one task and there are more than one task, the confirmation window is showed but the OnTaskDelete event is not fired at all, and the task is not deleted. Is it a know bug? Here's my code:

<telerik:RadGantt ID="RadGantt1" runat="server" AllowTaskDelete="true" RenderMode="Lightweight" DataSourceID="SqlDataSource1" DependenciesDataSourceID="SqlDataSource2"
        OnTaskInsert="RadGantt1_TaskInsert" OnTaskUpdate="RadGantt1_TaskUpdate" OnTaskDelete="RadGantt1_TaskDelete"
        OnDependencyDelete="RadGantt1_DependencyDelete" OnDependencyInsert="RadGantt1_DependencyInsert">
        <DataBindings>
            <TasksDataBindings IdField="ID" ParentIdField="ParentID" StartField="Start" EndField="End" TitleField="Title" PercentCompleteField="PercentComplete"
                               SummaryField="Summary" ExpandedField="Expanded"/>
            <DependenciesDataBindings TypeField="Type" IdField="ID" PredecessorIdField="PredecessorID" SuccessorIdField="SuccessorID" />
        </DataBindings>
    </telerik:RadGantt>
 
    <asp:SqlDataSource runat="server" ID="SqlDataSource1"
        ConnectionString="<%$ ConnectionStrings:LocalSqlServer %>"
        DeleteCommand="DELETE FROM [GanttTasks] WHERE [ID] = @ID"
        InsertCommand="INSERT INTO [GanttTasks] ([ParentID], [OrderID], [Title], [Start], [End], [PercentComplete], [Expanded], [Summary]) VALUES (@ParentID, @OrderID, @Title, @Start, @End, @PercentComplete, @Expanded, @Summary)"
        SelectCommand="SELECT * FROM [GanttTasks] WHERE [ORderID] != -1"
        UpdateCommand="UPDATE [GanttTasks] SET [ParentID] = @ParentID, [OrderID] = @OrderID, [Title] = @Title, [Start] = @Start, [End] = @End, [PercentComplete] = @PercentComplete, [Expanded] = @Expanded, [Summary] = @Summary WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="ParentID" Type="Int32" />
            <asp:Parameter Name="OrderID" Type="Int32" />
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="Start" Type="DateTime" />
            <asp:Parameter Name="End" Type="DateTime" />
            <asp:Parameter Name="PercentComplete" Type="Decimal" />
            <asp:Parameter Name="Expanded" Type="Boolean" />
            <asp:Parameter Name="Summary" Type="Boolean" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="ParentID" Type="Int32" />
            <asp:Parameter Name="OrderID" Type="Int32" />
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="Start" Type="DateTime" />
            <asp:Parameter Name="End" Type="DateTime" />
            <asp:Parameter Name="PercentComplete" Type="Decimal" />
            <asp:Parameter Name="Expanded" Type="Boolean" />
            <asp:Parameter Name="Summary" Type="Boolean" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
protected void RadGantt1_TaskInsert(object sender, Telerik.Web.UI.Gantt.TaskEventArgs e)
        {
            Telerik.Web.UI.Gantt.Task nouvelTache = (Telerik.Web.UI.Gantt.Task)e.Tasks.FirstOrDefault();
 
            if (nouvelTache.ParentID != null)
                SqlDataSource1.InsertParameters["ParentID"].DefaultValue = nouvelTache.ParentID.ToString();
 
            SqlDataSource1.InsertParameters["OrderID"].DefaultValue = nouvelTache.OrderID.ToString();
            SqlDataSource1.InsertParameters["Title"].DefaultValue = nouvelTache.Title;
            SqlDataSource1.InsertParameters["Start"].DefaultValue = nouvelTache.Start.ToString();
            SqlDataSource1.InsertParameters["End"].DefaultValue = nouvelTache.End.ToString();
            SqlDataSource1.InsertParameters["PercentComplete"].DefaultValue = nouvelTache.PercentComplete.ToString();
            SqlDataSource1.InsertParameters["Expanded"].DefaultValue = nouvelTache.Expanded.ToString();
            SqlDataSource1.InsertParameters["Summary"].DefaultValue = nouvelTache.Summary.ToString();
        }
 
        protected void RadGantt1_TaskUpdate(object sender, Telerik.Web.UI.Gantt.TaskEventArgs e)
        {
            Telerik.Web.UI.Gantt.Task tacheModifiee = (Telerik.Web.UI.Gantt.Task)e.Tasks.FirstOrDefault();
 
            SqlDataSource1.UpdateParameters["OrderID"].DefaultValue = tacheModifiee.OrderID == null ? "0" : tacheModifiee.OrderID.ToString();
            SqlDataSource1.UpdateParameters["Title"].DefaultValue = tacheModifiee.Title;
            SqlDataSource1.UpdateParameters["Start"].DefaultValue = tacheModifiee.Start.ToString();
            SqlDataSource1.UpdateParameters["End"].DefaultValue = tacheModifiee.End.ToString();
            SqlDataSource1.UpdateParameters["PercentComplete"].DefaultValue = tacheModifiee.PercentComplete.ToString();
            SqlDataSource1.UpdateParameters["Expanded"].DefaultValue = tacheModifiee.Expanded.ToString();
            SqlDataSource1.UpdateParameters["Summary"].DefaultValue = tacheModifiee.Summary.ToString();
        }
 
        protected void RadGantt1_TaskDelete(object sender, Telerik.Web.UI.Gantt.TaskEventArgs e)
        {
            foreach (Telerik.Web.UI.Gantt.Task tacheSuprimmee in e.Tasks)
            {
                SqlDataSource1.DeleteParameters["ID"].DefaultValue = tacheSuprimmee.ID.ToString();
                SqlDataSource1.Delete();
            }
        }

1 Answer, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 04 May 2017, 10:27 AM
Hello Hugo,

Here is a screencast demonstrating the behavior of the attached project where the DeleteTask event is called as expected. 

Would you please check if there are any JavaScript errors in the Browser console? 

If there aren't any, would you please modify the attached project so that it replicates the issue and send it back to us (excluding the BIN folder) in an official support ticket along with more detailed steps for reproducing it? Thus, we would be able to investigate locally and help you more efficiently.

Regards,
Peter Milchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Gantt
Asked by
Hugo
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or