1
votes

I have used Kendo UI grid with inline editing, all filed received in controller but date field not receiving why?

This is my code, please help me

Grid---

$(document).ready(function() {
                    $("#orders-grid").kendoGrid({
                        dataSource: {
                            type: "json",
                            transport: {
                                read: {
                                    url: "@Html.Raw(Url.Action("CustomerList", "Customer"))",
                                    type: "POST",
                                    dataType: "json",
                                },
                                create: {
                                    url: "@Html.Raw(Url.Action("CustomerAdd", "Customer"))",
                                    type: "POST",
                                    dataType: "json"
                                },
                                update: {
                                    url:"@Html.Raw(Url.Action("CustomerUpdate", "Customer"))",
                                    type: "POST",
                                    dataType: "json"
                                },
                                destroy: {
                                    url: "@Html.Raw(Url.Action("CustomerDelete", "Customer"))",
                                    type: "POST",
                                    dataType: "json"
                                },

                            },

                            schema: {
                                data: "Data",
                                total: "Total",
                                errors: "Errors",
                                model: {
                                    id: "Id",
                                    fields: {
                                        stfName: { editable: true, type: "string", validation: { required: true } },
                                        Id: { editable: false, type: "number" },
                                        stmName: { editable: true, type: "string", validation: { required: true } },
                                        dtdob: { editable: true, type: "Date",format : "dd/MMM/yyyy", validation: { required: true } },
                                        strefName: { editable: true, type: "string", validation: { required: true } },
                                    }
                                }
                            },
                            requestEnd: function (e) {
                                if (e.type == "create" || e.type == "update") {
                                    this.read();
                                }
                            },
                            error: function(e) {
                                //display_kendoui_grid_error(e);
                                // Cancel the changes
                                this.cancelChanges();
                            },
                            pageSize: 10,
                            serverPaging: true,
                            serverFiltering: true,
                            serverSorting: true
                        },
                        pageable: {
                            refresh: true,
                            pageSizes: [10]
                        }, //scrollable: false,
                        // dataBound: onDataBound,
                        sortable: true,
                        scrollable: {
                            virtual: true
                        },
                        toolbar: ["create"],
                        editable: {
                            confirmation: false,
                            mode: "inline"
                        },
                        columns: [
                            {
                                field: "Id",
                                title: "ID",
                                width: 50
                            },{
                                field: "stfName",
                                title: "First Name",
                                //attributes: { "class": "upper" },
                                width: 200
                            },
                                {
                                    field: "dtdob",
                                    title: "D.O.B.",
                                    //editor: customDateEditor,
                                    type: "Date",
                                    template: "#=kendo.toString(dtdob,'dd/MMM/yyyy')#",
                                    //template: '<input type="date" name="dtdob" />',
                                   width: 200,
                                   //parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"]

                                },
                                {
                                    field: "strefName",
                                    title: "Reference",
                                    width: 200
                                },
                            {
                            command: [{
                                name: "edit",
                                text: "Edit"
                            }, {
                                name: "destroy",
                                text: "Delete"
                    }],
                       width: 200,
                    filterable: true
                    }]
                    });

                    var customDateEditor = function (container, options) {
                        $('<input />')
                            .appendTo(container)
                            .kendoDatePicker({
                                format: "dd/MMM/yyyy"
                            });
                    };
                    });
--model

public partial class tblCustomer { public int Id { get; set; } public string stfName { get; set; } public DateTime dtdob { get; set; } } }

Controller----

    public ActionResult CustomerUpdate(tblCustomer model) <-All Value receive  in model except date field dtdob
            {
    }

I have check in firebug there is ajax call and all fields pass properly event date too, but not receiving in controller why?

Regards,
Vinit Patel
1

1 Answers

1
votes

Please go through the link given below. It does have couple of solutions for the issue you are fixing. Please revert if the issue persists.

Passing dates from Kendo UI to ASP.NET MVC