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

Datepickers in Grid

1 Answer 322 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vauneen
Top achievements
Rank 1
Vauneen asked on 19 Mar 2012, 12:55 PM
I have a very odd problem, my editable grid has a date field (ExpiryDate), so there is one in every line (row).
If i edit a row and i change the contents of the datefield, i 'lose' the variable ExpiryDate from my POST vars completely. (if i dont edit the date field, but i edit other fields (text) my code works perfectly.)
According to Firebug, the parameter called ExpiryDate is not even in the Post values (unless of course i didnt trigger the date picker flyout.
Obviously there is something i'm doing wrong. Please could someone take a look.
This happens if i edit inline, popup or incell.
Maybe i should be initializing the datepicker evertime i use it? but where?
Please help?

(i have a php/mysql datasoure and CRUD setup)

      
            $("#grid").kendoGrid({
                dataSource: {
                    transport: {
                        read: "data/users.php",
                        update: {
                            url: "data/users.php",
                            type: "POST"
                        },
                        destroy: {
                            url: "data/users.php",
                            type: "DELETE"
                        },
                        create: {
                            url: "data/users.php",
                            type: "PUT"
                        }
                    },
                    error: function(e) {
                        alert(e.responseText);
                    },
                    schema: {
                        data: "data",
                        model: {
                            id: "ID",
                            fields: {
                                EmailAddress: { validation: { required: true}, type: "string" },
                                FirstName: { validation: { required: true}, type: "string"  },
                                SecondName: { validation: { required: true}, type: "string" },
                                AdvertType: { validation: { required: true}, type: "string"},
                                SubscriptionType: {  validation: { required: true}, type: "string" },
                                ActivationCode: { validation: { required: true}, type: "string" },
                                ExpiryDate: { editable: true, type: "date", parse: function(value) { return kendo.toString(value) } }
                            }
                        }
                    }
                },
                    
                pageable: true,
                height: 400,
                toolbar: ["create"],
                columns: [
                    { field: "EmailAddress", width: "250px" },
                    { field: "FirstName", width: "150px" },
                    { field: "SecondName", width: "150px" },
                    { field: "AdvertType", width: "100px" }, //, editor: advertTypeEditor },                    
                    { field: "SubscriptionType",  width: "100px" },
                    { field: "ActivationCode", width: "150px" },
                    { field: "ExpiryDate", width: "150px", format: "{0:dd-MM-yyyy}" },
                    { command: ["edit", "destroy"], title: " ", width: "200px" }
                ],
                //editable: "popup",
                editable: "incell",
                detailTemplate: kendo.template($("#template").html()),
                detailInit: detailInit,
                        toolbar: ["create", "save", "cancel"],

            });

1 Answer, 1 is accepted

Sort by
0
Vauneen
Top achievements
Rank 1
answered on 21 Mar 2012, 03:27 PM
Managed to fix this with parameter map:
i put this in my datasource.transport:
                        parameterMap: function(options, operation) {
                            return kendo.stringify(options);
                        }


Then, once submitted, all post info was in JSON xml format so i used this to access the info:
    $json = file_get_contents('php://input') ;     
    $obj = json_decode($json);
    $ExpiryDate   = $obj->{'ExpiryDate'};


Working now :)

Vauneen


Tags
Grid
Asked by
Vauneen
Top achievements
Rank 1
Answers by
Vauneen
Top achievements
Rank 1
Share this question
or