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

Kendo UI Scheduler Resources not binding

1 Answer 61 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
Sathis
Top achievements
Rank 1
Sathis asked on 11 May 2016, 11:10 AM

I am doing a booking system with Kendo UI Scheduler, once I delete one event, it always call the POST action instead of the DELETE action declared in my Odata API.

 [EnableQuery]
        public IQueryable<NeedScheduler> Get()
        {
            return (from cn in Context.CorporateNeeds
                    select new NeedScheduler()
                    {
                        NeedId = cn.NeedId, 
                        ObjectTypeId = cn.ObjectTypeId,
                        EquipmentId = cn.EquipmentId,
                        ProjectId = cn.ProjectId, 
                        ProjectName = cn.ProjectName, 
                        NeedDescription = cn.NeedDescription, 
                        PlanningGroupDescription = cn.PlanningGroupDescription, 
                        DistrictDescription = cn.DistrictDescription, 
                        ProjectedStartDate = cn.ProjectedStartDate, 
                        ProjectedEndDate = cn.ProjectedEndDate, 
                        MatchStatus = cn.MatchStatus, 
                        Comments = cn.Comments, 
                        EquipmentRequirementId = cn.EquipmentRequirementId, 
                        FromPES = cn.FromPES,
                        RegionDescription = "test",
                        Attendees = Context.CorporateNeeds.Take(3).Where(s => s.ObjectTypeId == cn.ObjectTypeId).Select(m => m.EquipmentId).ToList(),
                        IsAllDay=false
                    });
        }     

 

and My scheduler datasource is:

$("#scheduler").kendoScheduler({
            date: new Date(), //start date. set to today or whichever date the scheduler should land on  
            dateHeaderTemplate: kendo.template("<strong>#=kendo.toString(date, 'd/M')#</strong>"),
            resources: resourcesObjects,
            snap: false,
            timezone: "Etc/UTC",
            views: [
                "timelineWeek",
                {
                    type: "timelineMonth",
                    startTime: new Date("2013/6/13 00:00 AM"),
                    majorTick: 1440,
                    selected: true
                },
                "timelineYear"
               //we can add any other view from the available views or a custom view.
            ],
            allDaySlot: true,
            eventHeight: 40,
            height: 600,
            dataSource: {
                type: "odata-v4",
                transport: {
                    read: {
                        url: servicUrl + "NeedSchedulers?&token=" + token,
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                    },
                    update: {
                        url: function (data) {
                            return servicUrl + "NeedSchedulers('" + data.NeedId + "')?&token=" + token;
                        },
                        type: "PUT",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: function (response) {
                            return response;
                        },
                    },
                    create: {
                        url: servicUrl + "NeedSchedulers?&token=" + token,
                        type: "Post",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: function (response) {
                            return response;
                        },
                    },
                    destroy: {
                        url: function (data) {
                            return servicUrl + "NeedSchedulers('" + data.NeedId + "')?&token=" + token;
                        },
                        type: "DELETE",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                    },
                    parameterMap: function (data, operation) {
                        return JSON.stringify(data);
                    }
                },
                schema: {
                    data: function (data) {
                        return data.value;
                    },
                    total: function (data) {
                        return parseInt(data["odata.count"]);
                    },
                    model: {
                        id: "NeedId",
                        fields: {
                            NeedId: { from: "NeedId" },
                            ObjectTypeId: { from: "ObjectTypeId" },
                            EquipmentId: { from: "EquipmentId" },
                            ProjectId: { from: "ProjectId" },
                            title: { from: "ProjectName", nullable: true },
                            NeedDescription: { from: "NeedDescription" },
                            PlanningGroupDescription: { from: "PlanningGroupDescription" },
                            DistrictDescription: { from: "DistrictDescription" },
                            start: { type: "date", from: "ProjectedStartDate" },
                            end: { type: "date", from: "ProjectedEndDate" },
                            MatchStatus: { from: "MatchStatus", nullable: true },
                            Comments: { from: "Comments", nullable: true },
                            EquipmentRequirementId: { from: "EquipmentRequirementId", nullable: true },
                            RegionDescription: { from: "RegionDescription", nullable: true },
                            FromPES: { type: "boolean", from: "FromPES" },
                            isAllDay: { type: "boolean", from: "IsAllDay" },
                            Attendees: { type: "object" }
                        }
                    }
                },
                group: {
                    resources: ["Rooms", "Attendees"],
                    orientation: "vertical"
                },
                resources: [
                    {
                        field: "EquipmentId",
                        name: "EquipmentId",
                        dataSource: [
                            { text: "Meeting Room 101", value: "10002", color: "#6eb3fa" },
                            { text: "Meeting Room 201", value: "10001", color: "#f58a8a" }
                        ],
                        title: "EquipmentId"
                    },
                    {
                        field: "Attendees",
                        name: "Attendees",
                        dataSource: [
                            { text: "Alex", value: "10002", color: "#f8a398" },
                            { text: "Bob", value: "10001", color: "#51a0ed" },
                            { text: "Charlie", value: "10010", color: "#56ca85" }
                        ],
                        multiple: true,
                        title: "Attendees"
                    }
                ]
            }
        });
    });

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 16 May 2016, 06:37 AM
Hi Sathis,

The most probable reason for the Request Method to be "POST" when in fact you wish to destroy a scheduler event, is the lack of an event id

When you trigger a destroy event, the SchedulerDataSource gets synced and looks for the id of the scheduler event. If no id is found or the id value is the default one (e.g. 0), it is assumed as isNew and then an attempt is made to create a new SchedulerEvent. So instead of destroy, it calls create which is of type 'POST'.

Regards,
Dimo
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Fiddler Classic
Asked by
Sathis
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or