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

Error on drag and drop

1 Answer 71 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
adrian
Top achievements
Rank 1
adrian asked on 27 Apr 2015, 02:05 PM

Hello,

I have an issue when I do a drag and drop event when the resources' datasource is filled by a remote service. The error message is something like "cannot read property 'value' of null" (I'm not 100% sure of translation of the message since I have it in French).

I don't have any issue if I double-click on an task to edit it and then close it or if the datasource is hardcoded in json.

Thank you. 

 

 

    $(document).ready(function () {
                    initScheduler(new Date());
                });

                var initScheduler = function (date) {
                    kendo.culture("fr-BE");
                    $("#scheduler").kendoScheduler({
                        date: moment(date).hours(0).minutes(0).seconds(0).toDate(),
                        startTime: moment(date).hours(7).minutes(0).seconds(0).toDate(),
                        eventHeight: 40,
                        majorTick: 60,
                        eventTemplate: $("#event-template").html(),
                        dataSource: {
                            sync: function () {
                                this.read();
                            },
                            transport: {
                                batch: true,
                                read: {
                                    url: "Services/ServiceScheduler.asmx/GetInterventions",
                                    type: "POST",
                                    contentType: 'application/json; charset=utf-8',
                                    dataType: 'json',
                                    data: { pDate: moment(date).format("DD/MM/YYYY") },
                                    cache: false,
                                    complete: function (e) {
                                        $('<p>- Interventions ok</p>').appendTo('#console');
                                    }
                                },
                                update: {
                                    url: "Services/ServiceScheduler.asmx/UpdateInterventions",
                                    contentType: 'application/json; charset=utf-8',
                                    dataType: "json",
                                    type: "POST"
                                },
                                parameterMap: function (options, operation) {
                                    if (operation !== "read") {
                                        return kendo.stringify({ models: kendo.stringify(options) });
                                    } else {
                                        return kendo.stringify(options);
                                    }
                                }
                            },
                            schema: {
                                data: function (data) { // the data which the data source will be bound to is in the values field
                                    return data.d; //Sinon ça plante!
                                },
                                model: {
                                    id: "taskID",
                                    fields: {
                                        taskID: { from: "TaskId", type: "number" },
                                        roomId: { from: "RoomId", type: "number" },
                                        start: { from: "DateDebut", type: "date" },
                                        end: { from: "DateFin", type: "date" },
                                        title: { from: "Description" },
                                        description: { from: "Description" },
                                        PatientDescription: { from: "PatientDescription", editable: "true" }
                                    }
                                }
                            },
                            error: function (e) {
                                console.log(e.errors); // displays "Invalid query"
                            }
                        },
                        views: [
                            { type: "timeline", selected: true }
                        ],
                        group: {
                            resources: ["Salles"],
                            orientation: "vertical"
                        },
                        resources: [
                            {
                                field: "roomId",
                                name: "Salles",
                                dataSource: {
                                    transport: {
                                        read: {
                                            url: "Services/ServiceScheduler.asmx/GetRooms",
                                            dataType: "json",
                                            contentType: "application/json; charset=utf-8",
                                            type: "POST",
                                            complete: function (e) {
                                                $('<p>- Salles ok</p>').appendTo('#console');
                                            },
                                        }
                                    },
                                    schema: {
                                        // describe the result format
                                        data: function (data) { // the data which the data source will be bound to is in the values field
                                            return data.d; //Sinon ça plante!
                                        },
                                        model: {
                                            id: "value",
                                            fields: {
                                                value: { from: "IDAgenda", type: "number" },
                                                text: { from: "Description" }
                                            }
                                        },
                                        error: function (e) {
                                            console.log(e.errors); // displays "Invalid query"
                                            //alert("alalal");
                                        }
                                    }
                                },
                                parameterMap: function (options, operation) {
                                    if (operation !== "read" && options.models) {
                                        return { models: kendo.stringify(options.models) };
                                    }
                                }
                            }
                        ]
                    });
                }

 

Resources datasource from my remote service :

{"d":[{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1737,"Description":"Infirmière instrumentiste XXXXX"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1660,"Description":"Marie Curie Dicom"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1709,"Description":"Marie Curie Salle 0"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1689,"Description":"Marie Curie Salle 01"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1682,"Description":"Marie Curie Salle 02"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1548,"Description":"Marie Curie Salle 03"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1584,"Description":"Marie Curie Salle 04"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1688,"Description":"Marie Curie Salle 05"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1704,"Description":"Marie Curie Salle 06"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1728,"Description":"Marie Curie Salle 08"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1686,"Description":"Marie Curie Salle 09"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1585,"Description":"Marie Curie Salle 10"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1683,"Description":"Marie Curie Salle 12"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1736,"Description":"Marie Curie Salle Cathé Cardio"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1735,"Description":"Marie Curie Salle EEP"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1702,"Description":"Marie Curie salle endoscopie 1"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1703,"Description":"Marie Curie salle endoscopie 2"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1643,"Description":"Z Test Marie Curie Angio Vidéo"},{"__type":"GestionRendezVous.Services.RoomsTask","IDAgenda":1610,"Description":"Z Test Marie Curie Vidéo"}]}

 

 

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 29 Apr 2015, 09:13 AM
Hi Adrian,

After inspecting the provided code it seems that the reason for current behavior is the missing "schema.total" option in the resource dataSource:

total: function(data) {
      return data.d.length;
},

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Scheduler
Asked by
adrian
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or