radGantt problems with insert and delete

6 posts, 0 answers
  1. Silverback
    Silverback avatar
    9 posts
    Member since:
    Sep 2006

    Posted 26 Feb 2015 Link to this post

    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,
     
  2. Silverback
    Silverback avatar
    9 posts
    Member since:
    Sep 2006

    Posted 26 Feb 2015 in reply to Silverback Link to this post

    That should have been titled insert and update, sorry
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Silverback
    Silverback avatar
    9 posts
    Member since:
    Sep 2006

    Posted 26 Feb 2015 in reply to Silverback Link to this post

    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.
  5. Silverback
    Silverback avatar
    9 posts
    Member since:
    Sep 2006

    Posted 26 Feb 2015 in reply to Silverback Link to this post

    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


  6. Silverback
    Silverback avatar
    9 posts
    Member since:
    Sep 2006

    Posted 26 Feb 2015 in reply to Silverback Link to this post

    Ok, further issues. I am testing the custom provider so that additional fields can be supported.

    Following the instructions here : http://www.telerik.com/help/aspnet-ajax/gantt-custom-tasks-field.html

    When we go to step 1, http://www.telerik.com/help/aspnet-ajax/gantt-providers-customentityprovider.html, this doesn't explain much, but I eventually found a much more useful post at http://www.telerik.com/support/code-library/implementing-gantt-resources-with-custom-entity-provider which has a link to a codebase highlighting custom provider.

    However, once I implemented that, step 7 Update Provider GetTasks Method instructs me to change the provider including the line,

    Using db = New GanttDatabaseEntities()

    But I can't find a definition for this anywhere

    Plus it instructs step 8 Update Provider ToEntityTask Method which doesn't exist anywhere in the example library. Is there a working example or instructions anywhere?
  7. Felix
    Felix avatar
    42 posts
    Member since:
    Sep 2014

    Posted 05 Mar 2015 in reply to Silverback Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017