jquery ui - jqgrid and datepicker control giving error for new records -


i binded jqgrid json returned ajax. json has date in following format

11/1/2013 12:00:00 

in colmodel have specified following

{ name: 'datecol', index: 'signdate', width: '200', jsonmap: 'cell.signdate', editable: true, sorttype: 'date',                     editable: true, formatter: 'date', formatoptions: {                         srcformat: 'm-d-y h:i:s',                         newformat: 'y-m-d'                     }, editoptions: { datainit: initdateedit }, initdateedit = function(elem) {                 settimeout(function() {                     $(elem).datepicker({                         formatter: 'date', formatoptions: {                             srcformat: 'm-d-y h:i:s',                             newformat: 'yy-m-d'                         }                         autosize: true,                         showon: 'button', // dosn't work in searching dialog                         changeyear: true,                         changemonth: true,                         showbuttonpanel: true,                         showweek: true                     });                     //$(elem).focus();                 },100);             } 

this displays date correctly in grid as

2013-nov-01 

but when hit addnew record, popup comes , when select date , hit submit, in grid, new record showing

nan-undefined-nan 

in date column. wrong here?

when use same code given in link http://www.ok-soft-gmbh.com/jqgrid/localformediting.htm

edit works fine, when add new row, date comes nan-undefined-nan

please help.

i think reason of problem described wrong parameters of jquery ui datepicker use. use formatter , formatoptions parameters of datepicker not exists. instead of should use dateformat option format described here.

updated: main reason of problem describe wrong date format use. it's important understand srcformat , newformat of formatoptions should have php date format, jquery ui datepicker supports format described here example. input data 11/1/2013 12:00:00 am contains both date , time. on other side jquery ui datepicker support date only. because use newformat: 'yy-m-d' suppose want ignore time part of date. in case suggest use

formatter: 'date', formatoptions: {     srcformat: 'm/d/y',     newformat: 'y-m-d' } 

instead of

formatter: 'date', formatoptions: {     srcformat: 'm-d-y h:i:s',     newformat: 'y-m-d' } 

which use currently. next problem dateformat option of jquery ui datepicker. have use format corresponds srcformat, uses correct format (described here). in case of srcformat: 'm/d/y' should use dateformat: 'm/d/yy' instead of dateformat: 'yy-m-dd' use in jsfiddle demo.

the modified demo works correctly.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -