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

Uncaught TypeError: Cannot read property 'start' of undefined

3 Answers 577 Views
Gantt
This is a migrated thread and some comments may be shown as answers.
Prad
Top achievements
Rank 1
Prad asked on 21 Apr 2015, 07:16 AM

Hi, 

I'm using the Kendo UI Gantt Chart using the declaration from the basic usage on the demo page : http://demos.telerik.com/kendo-ui/gantt/index

 

My Declaration is pretty much a copy and paste from the site with a variation to an end-point that is serving static data, and the ID's have been changed to string to support GUID IDs:

<script src="~/Content/kendoui/js/kendo.all.min.js" type="text/javascript"></script>
    <link rel="stylesheet" href="~/Content/kendoui/styles/kendo.common.min.css"/>
    <link rel="stylesheet" href="~/Content/kendoui/styles/kendo.default.min.css" />
    <link rel="stylesheet" href="~/Content/kendoui/styles/kendo.dataviz.min.css" />
    <link rel="stylesheet" href="~/Content/kendoui/styles/kendo.dataviz.default.min.css" />

    <script>
    $(function () {

        var serviceRoot = "https://localhost:44301";
        var tasksDataSource = new kendo.data.GanttDataSource({
            batch: false,
            transport: {
                read: {
                    url: serviceRoot + "/Project/Tasks?ID=@Model.ID",
                    dataType: "jsonp"
                },
                update: {
                    url: serviceRoot + "/Project/UpdateTasks?ID=@Model.ID",
                    dataType: "jsonp"
                },
                destroy: {
                    url: serviceRoot + "/Project/DestroyTask?ID=@Model.ID",
                    dataType: "jsonp"
                },
                create: {
                    url: serviceRoot + "/Project/CreateTask?ID=@Model.ID",
                    dataType: "jsonp"
                },
                parameterMap: function (options, operation) {
                    if (operation !== "read") {
                        return { models: kendo.stringify(options.models || [options]) };
                    }
                }
            },
            schema: {
                model: {
                    id: "id",
                    fields: {
                        id: { from: "ID", type: "string" },
                        orderId: { from: "OrderID", type: "number", validation: { required: true } },
                        parentId: { from: "ParentID", type: "string", defaultValue: null, validation: { required: true } },
                        start: { from: "Start", type: "date" },
                        end: { from: "End", type: "date" },
                        title: { from: "Title", defaultValue: "", type: "string" },
                        percentComplete: { from: "PercentComplete", type: "number" },
                        summary: { from: "Summary", type: "boolean" },
                        expanded: { from: "Expanded", type: "boolean", defaultValue: true }
                    }
                }
            }
        });

        var dependenciesDataSource = new kendo.data.GanttDependencyDataSource({
            transport: {
                read: {
                    url: serviceRoot + "/Project/Dependencies?ID=@Model.ID",
                dataType: "jsonp"
            },
            update: {
                url: serviceRoot + "/Project/UpdateDependencies?ID=@Model.ID",
            dataType: "jsonp"
        },
            destroy: {
            url: serviceRoot + "/Project/DestroyDependencies?ID=@Model.ID",
                    dataType: "jsonp"
                },
                create: {
                    url: serviceRoot + "/Project/CreateDependency?ID=@Model.ID",
                    dataType: "jsonp"
                },
                parameterMap: function (options, operation) {
                    if (operation !== "read" && options.models) {
                        return { models: kendo.stringify(options.models) };
                    }
                }
            },
            schema: {
                model: {
                    id: "id",
                    fields: {
                        id: { from: "ID", type: "string" },
                        predecessorId: { from: "PredecessorID", type: "string" },
                        successorId: { from: "SuccessorID", type: "string" },
                        type: { from: "Type", type: "number" }
                    }
                }
            }
        });

        var gantt = $("#gantt").kendoGantt({
            dataSource: tasksDataSource,
            dependencies: dependenciesDataSource,
            views: [
                "day",
                { type: "week", selected: true },
                "month"
            ],
            columns: [
                { field: "id", title: "ID", width: 60 },
                { field: "title", title: "Title", editable: true, sortable: true },
                { field: "start", title: "Start Time", format: "{0:dd/MM/yyyy}", width: 100, editable: true, sortable: true },
                { field: "end", title: "End Time", format: "{0:dd/MM/yyyy}", width: 100, editable: true, sortable: true }
            ],
            height: 700,

            showWorkHours: false,
            showWorkDays: false,

            snap: false
        }).data("kendoGantt");

        $(document).bind("kendo:skinChange", function () {
            gantt.refresh();
        });
    });
    </script>

 

 

 

My end point is returning :

Tasks:

{"Data":[],"Total":0,"AggregateResults":null,"Errors":null}

 

Dependency:

{"Data":[],"Total":0,"AggregateResults":null,"Errors":null}

 

Its currently not returning anything since it is empty. 

However, I'm receiving "Uncaught TypeError: Cannot read property 'start' of undefined" on line 52 on kendo.all.min.js:52. I'm not sure what the error is, would you be able to please able to assist ? 

3 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 23 Apr 2015, 07:00 AM
Hello,

I tested the gantt widget with empty results being returned from the service, but I wasn't able to reproduce the error on my end. Could you confirm that you are using the latest version of the scripts? Perhaps it's an old bug that we've already fixed.

Regards,
Bozhidar
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Prad
Top achievements
Rank 1
answered on 25 Apr 2015, 11:07 AM

Hi, thanks for your reply. Its the latest version I believe, it was downloaded 2 days prior to posting this.

I'm receiving this as well when I press Add Task. Is this the same for you?

0
Prad
Top achievements
Rank 1
answered on 26 Apr 2015, 03:39 PM

Thanks for your assistance, but I've managed to sort it out. 

 

The reason for the error was that I was returning back a JSON and in intialisation I've indicated that it should be JSONP. I changed it to JSON and everything is now working. 

Tags
Gantt
Asked by
Prad
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Prad
Top achievements
Rank 1
Share this question
or