View Full Version : Row Editor sending wrong Date
AtulDawkhare
3 Aug 2012, 5:49 AM
Hi
Recently I have upgrade my Ext version from 4.0.7 to 4.1.1
In my model I have defined like
{name : 'StartDate',type: 'date' ,dateFormat: 'time'},
My Grid Column is
{
id: 'StartDateID',
width: 180,
text: 'Start Date',
dataIndex: 'StartDate',
renderer : Ext.util.Format.dateRenderer('m/d/Y'),
editor:{
allowBlank: true,
xtype:'datefield',
format:'m/d/Y',
editable: true},
sortable: false, groupable: false }
On Edit I am doing
My_Grid.on('edit', function(editor, e) {
e.store.sync();
}
After clicking on Update I used to get [with Ext 4.0.7 ] date value as
2012-08-04T00:00:00
but after upgrade with 4.1.1 I am getting date value as
310008e
Which I am not understanding.
Can you please suggest me what is missing here? Or else how to get proper date after clicking update button from RowEditor.
scottmartin
3 Aug 2012, 9:33 AM
Can you try updating your dateFormat to the format you want ... instead of 'time'
Scott.
AtulDawkhare
6 Aug 2012, 11:39 PM
Hi ,
Thanks for the reply.
The date which I am getting from server side is in timeStamp.
1346351400000
SO i have used the dateFormat as "time"
Can you please suggest what can be done ? to get the proper date at server side.
Please suggest code changes as well. so that I will get date, in readable format.
AtulDawkhare
10 Aug 2012, 2:53 AM
Can you please suggest me ?
friend
10 Aug 2012, 4:02 AM
Visit the Ext.Date (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext.Date) API documentation for a complete list of date/time formats.
AtulDawkhare
10 Aug 2012, 4:52 AM
I have tried changing the dataformat to my expected format but still I am getting the same date i.e
310008e
Also as per suggestion , if I change the dateFormat from the Modal to say "timestamp" Then I get date as "310008e0031am08p" But If I change the dateFormat to say "d/m/y" , then I get proper date, but I am not able to show the date in grid, as show in the below image with Red square.
Please suggest me the format which will return proper date, also in grid I can see it in "d/m/y" format. as shown in attached image.
37853
AtulDawkhare
10 Aug 2012, 11:26 PM
Plz suggest me.
kaiden.vo
11 Aug 2012, 6:19 AM
Look for submitFormat property or you can override the getSubmitValue().
Cheers,
scottmartin
11 Aug 2012, 9:48 AM
Did the post on SO solve your problem?
{name : 'StartDate',type: 'date' ,dateFormat: 'U'},
http://stackoverflow.com/questions/11900181/row-editor-sending-wrong-date
Scott.
AtulDawkhare
12 Aug 2012, 9:26 PM
No,
There also I have mentioned that same that,
I can see the return value in proper format, as I have mentioned in the Model. but when I gave the dateFormat at "u" , OR anything else, I am not able to see the date in Grid.
So please suggest me.
redraid
13 Aug 2012, 3:05 AM
Try this:
Ext.apply(Ext.JSON, {
encodeDate: function (o) {
return '"' + o.getFullYear() + "-"
+ pad(o.getMonth() + 1) + "-"
+ pad(o.getDate()) + "T"
+ pad(o.getHours()) + ":"
+ pad(o.getMinutes()) + ":"
+ pad(o.getSeconds()) + '"';
}
});
redraid
14 Aug 2012, 4:11 AM
Im got same error (im using timestamp format).
In 4.1.1 the format (dateFormat (http://testing/extjs-4.1.1/docs/index.html#!/api/Ext.data.Field-cfg-dateFormat)) string is also used when serializing Date fields for use by Writers, try:
{name : 'StartDate',type: 'date' ,dateFormat: 'Y-m-dTH:i:s'},
But you need to return from server date in same format.
AtulDawkhare
14 Aug 2012, 7:08 AM
As per your suggestion I have made changes in my model
{name : 'MilestoneBO_GridComponentId_startDate_columnId',type: 'date' ,dateFormat: 'Y-m-dTH:i:s'},
{name : 'MilestoneBO_GridComponentId_expectedEndDate_columnId',type: 'date' ,dateFormat: 'time'},
But because of this when first time the Grid gets load..
I can see as follows. Start Date as blank
37938
But When I choose the date using Row Editor I get the well formated date i.e.
2012-08-22IST00:00:00
But I should be able to see date as shown in the Expected End date column in the image.
Please suggest.
redraid
15 Aug 2012, 1:21 AM
You must return from server date in format specified in field dateFormat config
AtulDawkhare
15 Aug 2012, 8:38 PM
Since it was working fine in 4.0.7 but If this is case then I have to make changes in lot of files.
Is there any other solution for this ?
i.e. I can display the date very well on the Gird and at the same time I can get the date in proper format using Row Editor on server side when click on update button.
Please suggest.
eleftrik
10 Oct 2012, 8:37 AM
AtulDawkhare (http://www.sencha.com/forum/member.php?306903-AtulDawkhare), did you solve your problem?
I have the same issue: with ExtJS 4.1.0 date in a grid column was sent in english format (correct), with ExtJS 4.1.1 is sent in italian format (because I use dateFormat: 'd/m/Y')
jpurni
24 Apr 2013, 3:28 AM
I am facing the same issue .. Anyone found a solution ?
jpurni
24 Apr 2013, 5:08 AM
i receive the date from database as LONG format ,
so i added the below code in the model ,
dateFormat : 'Y-m-d',
convert:function(value,data){
if(value=='')
return '';
else if(value instanceof Date )
return value;
else
return new Date(parseInt(value));
},
So the convert function will format date if its long or return date if its an instance of date type.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.