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

Datepicker column not included when submitting

4 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 18 Jun 2012, 03:25 PM
Hi, Sorry if this is a repost on my post, I apologies for that. Btw, I tried doing it myself, but the column does not submit itself when creating or editing. Can you please help me with this? PS: All columns are just examples. Please do not based on their respective names.


Here's the grid:

$("#grid").kendoGrid({
                       dataSource: dataSource,
                       pageable: true,
                       height: 340,
                       toolbar: ["create"],
                       columns:
                           [{"field":"firstName","title":"First name"},{"field":"nickName","title":"Nick Name","template":"#= kendo.toString(nickName,'MM/dd/yyyy') #"},{"field":"lastName","width":"150px","editor":lastNameEditor},
{"command":"destroy","title":" ","width":"110px"}]                            ,
                            
                       editable: true
                   });
               });

Here's the DataSource: 


  var dataSource = new kendo.data.DataSource({
                         
                                parameterMap: function(options, operation) {
         
        //alert(operation);
             return kendo.stringify(options);
                                    if (operation !== "read" && options.models) {
                                        return {models: kendo.stringify(options.models)};
                                    }
                                   
                                    },
                 
                transport: {
                     
         read: {
dataType: "json",
 type: "POST",
data: {"SQLCMD":"SELECT * FROM gridTest","Table":["firstName","nickName","lastName"],"PrimaryKey":"peopleID"}
},
         update: {
            type: "POST"
         },
         destroy: {
             type: "POST"
          },
          create: {
              type: "POST",
               data: {
                req: ["firstName","nickName","lastName"]                }
               
               
           }
         },
                
         // determines if changes will be send to the server individually or as batch
         batch: false,
         //...
 
 
                       pageSize: 30,
                       data: blankData,
                       autoSync: true,
                       schema: {
                           model: {
                             id: "peopleID",
                             fields:
                                {
"peopleID":{"editable":false,"nullable":true},
"firstName":{"type":"string","validation":"required":true},"nullable":false,"defaultValue":""},
"nickName":{"type":"date","validation":{"required":true},"nullable":false,"parse":function(value) { return kendo.toString(value) }},
"lastName":{"type":"string","validation":"required":true},"nullable":false}}                             }
                           ,  parse: function (data) {
        // alert(data);
            return data;
        }
                       }
                    });


Please, I hope you can help me. Thanks! 

4 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 21 Jun 2012, 10:37 AM
Hello Mike,

The only known problem that can cause this behaviour is with jQuery.param() - in jQuery v.1.7.1 it does not serialize date objects properly. This could be reproduced that without Kendo:
jQuery.param({foo: 1}); // => "foo=1" - SUCCESS!
jQuery.param({bar: new Date()}); // => "" - OUCH!

I noticed that you have defined the parameterMap function and are stringifying the options manually, so I assume that the issue is not connected with the param method. Could you please check if in the parameterMap the date field is part of the options.models? Is the problem occurs only in a specific browser? A small but runnable project that reproduces issue will be greatly appreciated. Thus way we would be able to investigate the case in details and do our best to provide you with a faster and accurate solution.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mike
Top achievements
Rank 1
answered on 21 Jun 2012, 04:36 PM
Hello Alex,


Thank you for your warm reply. I though this thread was already forgotten.

Anyway, the transport function is actually a workaround to fix the Email column that was not supported by kendoui datasource.

I tried using firebug and saw that the date column was not included when sending to the server. I don't know why. 
and I alsotested it with the latest browsers (Chrome and FF) still no luck

I have prepared a working page here: http://unoprojects.com/egrid/gridtest.php


I'll be waiting for your reply (hopefully its a solution)

Also, if you can post an example that was already tested with CRUD abilities, I can read it and try to reproduce it by myself. 


Until then, Thank you for your support! 

0
Alexander Valchev
Telerik team
answered on 26 Jun 2012, 09:41 AM
Hello Mike,

The parameterMap is part of the transport and in the way it is defined at the moment the function is never being hit. The correct syntax is:
var dataSource = new kendo.data.DataSource({
    transport: {
        read: { ... },
        parameterMap: function() {
            //....
        }
    }
}

In addition I noticed that the date field parser returns a string, not a valid JavaScript date. Even though that most probably this is not the cause of non submitting date issue, I would recommend store in this field a Date objects. 
"LastName": {
    "type": "date",
    "validation": { "required": true },
    "nullable": false,
    "parse": function (value) {
        return kendo.toString(value) //returns string
    }
}

Please try to suggested changes and let me know if the problem still persists.
Thank you in advance.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
James
Top achievements
Rank 1
answered on 17 Oct 2012, 09:38 AM
If anyone is reading this, and none of the other solutions work for them, the best solution I have found is simply to update jQuery from 1.7 to 1.8.
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Mike
Top achievements
Rank 1
James
Top achievements
Rank 1
Share this question
or