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

radGantt problems with insert and delete

4 Answers 183 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
Silverback
Top achievements
Rank 1
Silverback asked on 26 Feb 2015, 12:57 PM
I am trying to implement radGantt per some of the demos, as it looks to be a very nice control indeed. Obviously it works ok on the demo page here : http://demos.telerik.com/aspnet-ajax/gantt/examples/overview/defaultvb.aspx

I would copy this page directly, and try and get it working, however Telerik.Web.SessionDS cannot be found, hence the tag can't be registered, and the page doesn't work. I am using the latest build, 2015.1.225.45. That's problem one.

Now at one point, I had insert working, which has subsequently stopped during some of the cobbling together of different demos. Current asp code is as follows :

  <div class="demo-container no-bg">
        <rad:RadGantt ID="RadGantt1"
            runat="server"
            DataSourceID="SqlDataSource1"
            DependenciesDataSourceID="SqlDataSource2"
            ReadOnly="false"
            SelectedView="WeekView" AutoGenerateColumns="false"  >
            <Columns>
                <rad:GanttBoundColumn DataField="Title" DataType="String" Width="120px"></rad:GanttBoundColumn>
                <rad:GanttBoundColumn DataField="Start" DataType="DateTime" DataFormatString="dd/MM/yy" Width="40px"></rad:GanttBoundColumn>
                <rad:GanttBoundColumn DataField="End" DataType="DateTime" DataFormatString="dd/MM/yy" Width="40px"></rad:GanttBoundColumn>
            </Columns>
 
            <DataBindings>
                <TasksDataBindings
                    IdField="ID" ParentIdField="ParentID"
                    StartField="Start" EndField="End"
                    OrderIdField="OrderID"
                    SummaryField="Summary"
                    TitleField="Title" PercentCompleteField="PercentComplete" />
                <DependenciesDataBindings
                    TypeField="Type" IdField="ID"
                    PredecessorIdField="PredecessorID"
                    SuccessorIdField="SuccessorID" />
            </DataBindings>
        </rad:RadGantt>
    </div>
 
    <asp:SqlDataSource runat="server" ID="SqlDataSource1"
        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]"
        UpdateCommand="UPDATE [GanttTasks] SET  [Title] = @Title WHERE [ID] = @ID"
        />
    <asp:SqlDataSource runat="server" ID="SqlDataSource2" SelectCommand="SELECT * FROM [GanttDependencies]" />

There is a radScriptManager and a radWindowManager out in the master page, with default settings.

At the moment, insert does the postback, but does nothing in the database.

If I try an update, whether double clicking the task on the left hand pane, or the right hand pane, on save I just get the spinning ajax icon. Normally I would expect there to be something amiss with the UPDATE statement causing an an error during the postback, but in this case the update occurs and you can see the results in the database directly. If you refresh the page you see the update reflected in the Gantt chart.

What's additionally frustrating is that when I am trying to use the developer tools to see what's going on in the response headers, I suspect Kendo is getting in the way and it reports script timeout errors. This doesn't occur if I have the dev console off.

What would really help is a demo ( preferably not in C# ) where I can take care of CRUD directly and get at the values in the Gantt control myself. I saw one posted using LINQ but I really don't want to go down that route, I want to stick with our typical environment of parameters/stored procedure calls.

Aside from that, a very useful feature for AJAX enabled controls would be to be able to turn AJAX off, and force a full postback so any background errors can be hunted down more easily.

Thanks in advance,
 

4 Answers, 1 is accepted

Sort by
0
Silverback
Top achievements
Rank 1
answered on 26 Feb 2015, 01:09 PM
That should have been titled insert and update, sorry
0
Silverback
Top achievements
Rank 1
answered on 26 Feb 2015, 01:35 PM
Ok, so I resolved the SessionDS thing, found the source for that. But as described, I shouldn't be using it anyway, which just takes me straight back to problem two, no insert or update.
0
Silverback
Top achievements
Rank 1
answered on 26 Feb 2015, 02:12 PM
And as per usual, having struggled with this for a day, as soon as I ask for help, I figure it out. To help out anyone else out there, here's my revised code :


  <div class="demo-container no-bg">
        <rad:RadGantt ID="RadGantt1"
            runat="server"
            DataSourceID="SqlDataSource1"
            DependenciesDataSourceID="SqlDataSource2"
            ReadOnly="false"
            SelectedView="WeekView" AutoGenerateColumns="false" DisplayDeleteConfirmation="true"  >
            <Columns>
                <rad:GanttBoundColumn DataField="Title" DataType="String" Width="120px"></rad:GanttBoundColumn>
                <rad:GanttBoundColumn DataField="Start" DataType="DateTime" DataFormatString="dd/MM/yy" Width="40px"></rad:GanttBoundColumn>
                <rad:GanttBoundColumn DataField="End" DataType="DateTime" DataFormatString="dd/MM/yy" Width="40px"></rad:GanttBoundColumn>
            </Columns>
 
            <DataBindings>
                <TasksDataBindings
                    IdField="ID" ParentIdField="ParentID"
                    StartField="Start" EndField="End"
                    OrderIdField="OrderID"
                    SummaryField="Summary"
                    TitleField="Title" PercentCompleteField="PercentComplete" />
                <DependenciesDataBindings
                    TypeField="Type" IdField="ID"
                    PredecessorIdField="PredecessorID"
                    SuccessorIdField="SuccessorID" />
            </DataBindings>
        </rad:RadGantt>
    </div>
 
    <asp:SqlDataSource runat="server" ID="SqlDataSource1"
        SelectCommand="SELECT * FROM [GanttTasks]"
    />
    <asp:SqlDataSource runat="server" ID="SqlDataSource2" SelectCommand="SELECT * FROM [GanttDependencies]" />
 

and the code behind

    Protected Sub RadGantt1_TaskInsert(sender As Object, e As TaskEventArgs) Handles RadGantt1.TaskInsert

        Dim sb As New StringBuilder
        sb.AppendLine("DECLARE @ParentID INT ")
        sb.AppendLine("DECLARE @OrderID INT ")
        sb.AppendLine("DECLARE @Title VARCHAR(MAX) ")
        sb.AppendLine("DECLARE @Start DATE")
        sb.AppendLine("DECLARE @End DATE")
        sb.AppendLine("DECLARE @PercentComplete DECIMAL(5,2) ")
        sb.AppendLine("DECLARE @Expanded BIT ")
        sb.AppendLine("DECLARE @Summary BIT ")

        For Each T As Task In e.Tasks

            If Not T.ParentID Is Nothing Then sb.AppendLine("SET @ParentID = " & T.ParentID)

            sb.AppendLine("SET @OrderID = " & T.OrderID)
            sb.AppendLine("SET @Title = '" & T.Title & "'")
            sb.AppendLine("SET @Start = '" & T.Start.ToString("yyyy-MM-dd") & "'")
            sb.AppendLine("SET @End = '" & T.End.ToString("yyyy-MM-dd") & "'")
            sb.AppendLine("SET @PercentComplete = " & T.PercentComplete)
            sb.AppendLine("SET @Expanded = " & IIf(T.Expanded, 1, 0))
            sb.AppendLine("SET @Summary = " & IIf(T.Summary, 1, 0))

            sb.AppendLine("INSERT INTO [GanttTasks] ([ParentID], [OrderID], [Title], [Start], [End], [PercentComplete], [Expanded], [Summary]) VALUES (@ParentID, @OrderID, @Title, @Start, @End, @PercentComplete, @Expanded, @Summary)")
        Next

        Using R As New RS
            R.Execute(sb.ToString)
        End Using
    End Sub


0
Felix
Top achievements
Rank 1
answered on 05 Mar 2015, 07:57 AM
Hi Silverback,

you're right. The explanation for the custom gantt provider is quite short. But you should look at the code library for the gantt control under http://www.telerik.com/support/code-library/aspnet-ajax/gantt. There are several examples which should work, e.g. http://www.telerik.com/support/code-library/gantt-custom-columns which contains an implementation of an custom gantt provider and a custom column.

Regards,
Felix
Tags
Gantt
Asked by
Silverback
Top achievements
Rank 1
Answers by
Silverback
Top achievements
Rank 1
Felix
Top achievements
Rank 1
Share this question
or