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

Create operation doesen't work

4 Answers 87 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Mattia
Top achievements
Rank 1
Mattia asked on 26 Mar 2014, 05:39 PM
Hi all,
I need help with the "Create" operation.
When I create a new task, the Scheduler doesn't send any data to the Controller method.

My C# object is:

public class Reservation : ISchedulerEvent
    {
        public virtual int IdReservation { get; set; }
        public virtual int? IdWorker { get; set; }
        public virtual int IdRoom { get; set; }
        public virtual string Title { get; set; }
        public virtual string Description { get; set; }
        public virtual DateTime Start { get; set; }
        public virtual string StartTimezone { get; set; }
        public virtual DateTime End { get; set; }
        public virtual string EndTimezone { get; set; }
        public virtual string RecurrenceRule { get; set; }
        public virtual string RecurrenceException { get; set; }
        public virtual bool IsAllDay { get; set; }
        public virtual DateTime ReservationDate { get; set; }
    }

and the Javascript is:

$("#scheduler").kendoScheduler({
        date: new Date("2014/3/25"),
        startTime: new Date("2014/3/25 07:00 AM"),
        height: 600,
        views: [
            "day",
            { type: "workWeek", selected: true },
            "week",
            "month",
            "agenda"
        ],
        timezone: "Etc/UTC",
        dataSource: {
            batch: true,
            transport: {
                read: {
                    url: "/Reservation/Read",
                    dataType: "json",
                    type: "POST"
                },
                update: {
                    url: "/Reservation/Update",
                    dataType: "json",
                    type: "POST"
                },
                create: {
                    url: "/Reservation/Create",
                    dataType: "json",
                    type: "POST"
                },
                destroy: {
                    url: "/Reservation/Delete",
                    dataType: "json",
                    type: "POST"
                },
                parameterMap: function (options, operation) {
                    if (operation !== "read" && options.models) {
                        return { models: kendo.stringify(options.models) };
                    }
                }
            },
            schema: {
                model: {
                    id: "idReservation",
                    fields: {
                        idReservation: { from: "IdReservation", type: "number", defaultValue: 1 },
                        worker: { from: "IdWorker", type: "number", defaultValue: 1 },
                        roomId: { from: "IdRoom", type: "number" },
                        title: { from: "Title", defaultValue: "No title" },
                        description: { from: "Description", defaultValue: "" },
                        start: { from: "Start", type: "date" },
                        startTimezone: { from: "StartTimezone", defaultValue: null },
                        end: { from: "End", type: "date" },
                        endTimezone: { from: "EndTimezone", defaultValue: null },
                        recurrenceRule: { from: "RecurrenceRule" , defaultValue: null },
                        recurrenceException: { from: "RecurrenceException", defaultValue: null },
                        isAllDay: { from: "IsAllDay", type: "boolean", defaultValue: false },
                        reservationDate: { from: "ReservationDate", type: "date", defaultValue: new Date() }
                    }
                }
            }
        }
    });

and, this is my "Create" (MVC Controller) method is:

public virtual JsonResult Create([DataSourceRequest] DataSourceRequest request, Reservation reservation)
{
    ...
}

Please, can anyone help me to know why the properties in the "reservation" parameter ("Create" method) are all empties?

Thanks

4 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 28 Mar 2014, 03:34 PM
Hi Mattia,

In current case you should set the Scheduler DataSource type to "aspnetmvc-ajax" and include the "kendo.aspnetmvc.min.js" script to the project. Please check the example below:

<script>
    $("#scheduler").kendoScheduler({
        date: new Date("2014/3/25"),
        startTime: new Date("2014/3/25 07:00 AM"),
        height: 600,
        views: [
            "day",
            { type: "workWeek", selected: true },
            "week",
            "month",
            "agenda"
        ],
        timezone: "Etc/UTC",
        dataSource: {
            type:"aspnetmvc-ajax"
            batch: true,
            transport: {

Also could you please elaborate more on why are you using the web version of the Scheduler instead the MVC wrapper (as it's build to support such configuration  by default)?

Regards,
Vladimir Iliev
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Mattia
Top achievements
Rank 1
answered on 28 Mar 2014, 04:31 PM
Thanks for the reply.

I tried, but it doesn't work.

"why are you using the web version of the Scheduler instead the MVC wrapper"?

good question! :-)

I am new with Telerik controls.

My Web site is an ASP.NET MVC application but I don't want to use the MVC wrapper.

Please, can you show me an example (or link) with the Web version of the Scheduler and an Action method write in ASP.NET MVC?

Thank you for your help

Mattia
0
Vladimir Iliev
Telerik team
answered on 31 Mar 2014, 06:35 AM
Hi Mattia,

You can check the following example in our CodeLibrary which demonstrates another possible solution of binding Scheduler for Web to ASP.NET MVC Controller:

Regards,
Vladimir Iliev
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Mattia
Top achievements
Rank 1
answered on 08 Apr 2014, 11:02 AM
I apologize for the delay.

Thank you very much for the help.

Your example was very helpful.
Tags
Scheduler
Asked by
Mattia
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Mattia
Top achievements
Rank 1
Share this question
or