Create operation doesen't work

5 posts, 0 answers
  1. Mattia
    Mattia avatar
    3 posts
    Member since:
    Mar 2014

    Posted 26 Mar 2014 Link to this post

    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
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 28 Mar 2014 Link to this post

    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.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Mattia
    Mattia avatar
    3 posts
    Member since:
    Mar 2014

    Posted 28 Mar 2014 in reply to Vladimir Iliev Link to this post

    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
  5. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 31 Mar 2014 Link to this post

    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.

     
  6. Mattia
    Mattia avatar
    3 posts
    Member since:
    Mar 2014

    Posted 08 Apr 2014 in reply to Vladimir Iliev Link to this post

    I apologize for the delay.

    Thank you very much for the help.

    Your example was very helpful.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready