Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
date problem
18/02/2014
15:43
Avatar
kgeerts
Member
Members
Forum Posts: 3
Member Since:
11/11/2013
sp_UserOfflineSmall Offline

Hi,

I think I found an error in the way jqGrid is handling dates.

I have normal grid set up with the demogrid grid and date  like this

{name:'invdate',index:'invdate', width:80,editable:true,editoptions:{size:10}, formatter: 'date', formatoptions: { srcformat:'Y-m-d', newformat: 'd/m/Y'}},  The build of my invoice is ok . BTW ...the date is saved in database like 2014-02-18 but then showed as it should be 18/02/2014 .  I then use the navGrid option to fill in a new date .

In the before Show form I default a date like this

function beforeShowForm(formId)

var today = new Date();

var dd=today.getDate();

var mm= totday.getMonth()+1;

var yyyy=today.getFullYear();

if (dd<10){

dd='0"+dd;}

if (mm<10){

mm='0'+mm;}

today = dd+'/'+mm+'/'+yyyy;

$(#invdate",formId).val(today);

this gives me todays value into the input screen .

In the data send via json it goes in the form 18/02/2014 which is so far so good.

(naturally I convert it to the used format 2014-02-18 before entering in the database .

When I auto redraw the grid things go ok .

BUT 

when I don't do anything with the postdata(and leave it to the default way) the entered data is wrong in the grid .

I have now (as a work arround ) altered the postdata back into the form 2004-02-18 (in the aftersubmit procedure) before leaving it up to the grid logic to display the new row . This goes ok but without 'aftersave' conversion its wrong .

Thanks

24/02/2014
17:35
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

This is old question and sorry that it is not documented well.

Set  reformatAfterEdit to true in the date field in colmodel like this:

{

   name:'invdate',

...

   formatter: 'date',

   formatoptions: {

       srcformat:'Y-m-d',

       newformat: 'd/m/Y',

       reformatAfterEdit : true

   }

}

Regards

 

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
25 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information