Populating Gantt via Services

2 posts, 0 answers
  1. Richard
    Richard avatar
    18 posts
    Member since:
    Jun 2014

    Posted 20 Aug 2014 Link to this post

    Having learnt that Gantt doesn't (yet) support passing models to views I am attempting to engineer a datasource/service driven Gantt chart.

    View is:
    <div class="gantt-wrapper">
        @(Html.Kendo().Gantt(Of IMS_2.Models.Task, IMS_2.Models.Dependency)().Name("gantt") _
        .Columns(Sub(columns)
                         columns.Bound(Function(c) c.ID).Title("ID").Width(50)
                         columns.Bound("title").Editable(True).Sortable(True)
                         columns.Bound("start").Title("Start Time").Format("{0:MM/dd/yyyy}").Width(100).Editable(True).Sortable(True)
                         columns.Bound("end").Title("End Time").Format("{0:MM/dd/yyyy}").Width(100).Editable(True).Sortable(True)
                 End Sub) _
              .Views(sub(views)
                             views.DayView()
                             views.WeekView(Function(weekView) weekView.Selected(True))
                             views.MonthView()
                             End Sub) _
                             .DataSource(Function(d) d.Read(Function(read) read.Action("ReadTasks", "Gantt")).Model(Sub(m)
                                                                                                                            m.Id(Function(f) f.ID)
                                                                                                                            m.ParentId(Function(f) f.ParentID)
                                                                                                                            m.OrderId(Function(f) f.OrderID)
                                                                                                                            m.Field(Function(f) f.Expanded)            
                                                                                                                    End Sub)))
    </div>

    The following is rendered but no gantt chart is displayed:
    <div class="gantt-wrapper">
        <div data-role="gantt" id="gantt"></div><script>
        jQuery(function(){jQuery("#gantt").kendoGantt({"columns":[{"title":"ID","width":50,"sortable":true,"field":"ID"},{"title":"Project Name","editable":true,"sortable":true,"field":"title"},{"title":"Start Time","format":"{0:MM/dd/yyyy}","width":100,"editable":true,"sortable":true,"field":"start"},{"title":"End Time","format":"{0:MM/dd/yyyy}","width":100,"editable":true,"sortable":true,"field":"end"}],"views":[{"type":"day"},{"selected":true,"type":"week"},{"type":"month"}],"dataSource":{"type":(function(){if(kendo.data.transports['aspnetmvc-ajax']){return 'aspnetmvc-ajax';} else{throw new Error('The kendo.aspnetmvc.min.js script is not included.');}})(),"transport":{"read":{"url":"/Gantt/ReadTasks"},"prefix":""},"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"id":"ID","fields":{"ID":{"type":"number"},"title":{"from":"Title","type":"string"},"start":{"from":"Start","type":"date"},"end":{"from":"End","type":"date"},"parentId":{"from":"ParentID","type":"number"},"orderId":{"from":"OrderID","type":"number"},"percentComplete":{"from":"PercentComplete","type":"number"},"expanded":{"from":"Expanded","type":"boolean"},"summary":{"from":"Summary","type":"boolean"}}}}},"dependencies":{"type":(function(){if(kendo.data.transports['aspnetmvc-ajax']){return 'aspnetmvc-ajax';} else{throw new Error('The kendo.aspnetmvc.min.js script is not included.');}})(),"transport":{"read":{"url":""},"prefix":""},"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"fields":{"DependencyID":{"type":"number"},"PredecessorId":{"type":"number"},"SuccessorId":{"type":"number"},"Type":{"type":"number"}}}}}});});
    </script>
    </div>
            </div>

    The controller datasource service is not being called (no breakpoints are hit).  Any help gratefully received!
    Thanks
  2. Richard
    Richard avatar
    18 posts
    Member since:
    Jun 2014

    Posted 21 Aug 2014 in reply to Richard Link to this post

    SELF SOLVED!

    Inspecting javascript errors revealed that the upgrade to 2014Q2 had not populated the files in my project.

    I now have a gantt chart (albeit blank)!

    Sorry for the self-induced confusion.
    R.
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top