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

Kendo Grid does not support date picker server update

3 Answers 235 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Yevgeniy
Top achievements
Rank 1
Yevgeniy asked on 06 Mar 2013, 07:00 PM
I can get the date to display using this code, however, when it get posted to the server it just posts it as 01/01/0001. Also, every-time edit is hit why does the date column become empty?     

iwofreportSource = new kendo.data.DataSource({
        transport:
            {
                read: {
                    url: '/iwof/get-iwof-report/',
                    dataType: 'json'
                },
                create: {
                    url: '/iwof/add-iwof-report',
                    dataType: 'json',
                    type: 'Post',
                    complete: function (e) {
                        $("#iwof").data("kendoGrid").dataSource.read();
                    }
                },
                update:
                {
                    url: '/iwof/update-iwof-report',
                    dataType: 'json',
                    type: 'Post',
                    complete: function (e) {
                        $("#iwof").data("kendoGrid").dataSource.read();
                    }
                },
                destroy: {
                    url: '/iwof/delete-iwof-report',
                    type: 'POST',
                    dataType: 'json'
                }
            },
        async: true,
        batch: false,
        pageSize: 10,
        schema: {
            "model": {
                id: "Id",
                fields: {
                    Id: { editable: false, nullable: true },
                    DueToAE: { editable: true, type: "date" },
                }
            }
        }
      
    });

    var grid = $("#iwof").kendoGrid({
        dataSource: iwofreportSource,
        scrollable: false,
        pageble: true,
        filterable: false,
        resizable: true,
        toolbar: ["create"],
        width: 1000,
        sortable: { mode: 'multiple' },
        pageable: {
            refresh: true,
            pageSizes: true
        },
        columns: [
            { field: "DueToAE", title: "Due To AE", format: "{0:MM/dd/yyyy}" },  
        ],
        editable: "inline", // enable inline editing

    });

3 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 08 Mar 2013, 12:15 PM
Hi Yevgeniy,

 
From the provided information it's not clear for us what exact reason for this behavior - could you please provide more information about your server-side code and post sample data that is returned from the server? Most probably the dates are send in incorrect format to the server - you can define parameterMap function to convert them to the correct format.

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Yevgeniy
Top achievements
Rank 1
answered on 08 Mar 2013, 02:06 PM
   This is the back end method that gets called
     public ActionResult AddIwofReport([DataSourceRequest] DataSourceRequest request, IwofReport report)
      {
            report.DateEntered = DateTime.Now.ToString();
            _session.Store(report);
            return Json(report);
    }

  This is the report object 
   [Serializable]
    public class Report
    {
        public int Id { get; set; }
        public string Zone { get; set; }
        public DateTime DueToAE { get; set; }
        public decimal Hours { get; set; }
        public string Instruction { get; set; }
    }

This is the data that gets sent to the server
"DueToAE":"\/Date(-62135578800000)\/"
 and it's recieved as
01/01/0001 EST etc...
Could you please show a working example with?
0
Vladimir Iliev
Telerik team
answered on 12 Mar 2013, 11:16 AM
Hi Yevgeniy,

 
Basically the date is send in invalid format to the server - in order to be understand by the default MVC Model Binder the parameters should be send in different format. I would suggest to include the kendo.aspnetmvc.min.js script and set the dataSource type to "aspnetmvc-ajax" which will load predefined settings for sending and receiving data from MVC controller.

e.g.:

iwofreportSource = new kendo.data.DataSource({
    type: "aspnetmvc-ajax",
    transport:
        {
            ...
Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Date/Time Pickers
Asked by
Yevgeniy
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Yevgeniy
Top achievements
Rank 1
Share this question
or