ModelBinder Doesn't Recognize Date

2 posts, 0 answers
  1. Jaime
    Jaime avatar
    61 posts
    Member since:
    Mar 2013

    Posted 22 Jul 2014 Link to this post

    Can't Send Start/End Date to Server

    When, I save my event the start and end dates don't get posted to the server. I can override the save event and do something like this. 
    e.event.start = kendo.toString(e.event.start, "u"); The values are then saved and the records it successfully added to the database.

    Why does this happen? 

  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2194 posts

    Posted 24 Jul 2014 Link to this post

    Hi Jaime,

    Basically you should use "parameterMap" function of the dataSource transport in order to stringify the current record correctly. Please check the example below:

    dataSource: {
        transport: {
            read: {
                url: "Home/Meetings_Read",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                type: "POST"
            },
            update: {
                url: "Home/Meetings_Update",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                type: "POST"
            },
            create: {
                url: "Home/Meetings_Create",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                type: "POST"
            },
            destroy: {
                url: "Home/Meetings_Destroy",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                type: "POST"
            },
            parameterMap: function (options, operation) {
                if (operation === "read") {
                    var scheduler = $("#scheduler").data("kendoScheduler");
                    var result = {
                        start: scheduler.view().startDate(),
                        end: scheduler.view().endDate()
                    }
                    return kendo.stringify(result);
                }
                return kendo.stringify(options);
            }
        },

    Regards,
    Vladimir Iliev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top