PDA

View Full Version : TimeField returns whole date/time format if remove extjs3.0 compat js file in EXTJS 4



bee
26 Sep 2011, 8:04 AM
Hi Guys,

I am in process of migrating EXT 3.x code to EXT 4.0 version. I use ext3 compat js file and when I execute the program using it I get following error for time field in my gridpanel.
ext3-core-compat.js:108[INFO][4.0][Ext.data.Store]: Registering implicit model Ext.data.Store.ImplicitModel-ext-gen2101.Please update your code to create a model explicitly.

So as it is info error I just ignored, but when I finished my migrationa nd removed my all ext3 compat js from my project, my timefield is now working properly It throws the time whole format as Tue Jan 01 2008 01:30:00 GMT.... in format. I didnt use any format for this in extjs3.x.
Please guide how Timefield works in EXTJS 4.0 and how to override the time format to get in proper normal time format.
28347

Thanks in adv.

skirtle
26 Sep 2011, 11:49 PM
What do you mean by timefield? From that tiny screenshot it looks like you're trying to put a date in a grid column. Is that what you mean? It might help if you posted the relevant code.

bee
27 Sep 2011, 1:10 AM
Hi Thanks, No I am not inserting date in the field, It is automatically taken by timefield.
I have GridPanel and row editing .In Active time column ,it takes whole date/time format in field. Below is my code for date field and time field.


{header : 'Active Date',
align : 'left',
dataIndex : 'active_date',
id : 'active_date',
format : 'd/m/Y',
renderer : Ext.util.Format.dateRenderer('d/m/Y'),
editor : {xtype: 'datefield',format : 'd/m/Y'}
},
{xtype : 'gridcolumn',
dataIndex : 'active_time',
header : 'Active Time',
id : 'active_time',
editor : {xtype : 'timefield',format : 'H:i'},
sortable : true }


Do I need to specify some time format their explicitly ? Please find my before updating row and after updating in screenshot.
Below image after updating record,
28359
before updating looks like below image
28360

skirtle
27 Sep 2011, 2:20 AM
That code is really hard to read. I don't know how it looks on your screen but for me there are no newlines in it.

The date string you are seeing in ExtJS 4 appears to be the standard string representation of a JavaScript Date object. If you want to display it as a time string you'll need a suitable renderer or format. Note that the format option is only valid on a datecolumn, not a standard column.

bee
27 Sep 2011, 2:53 AM
Ok. I modified my code in last post and I hope you are able to read properly. I am using xtype as gridcoulmn for timefield (and as field timefield ) . So do you suggest me to change to datecolumn ? Do we have any specific render for time ?

skirtle
27 Sep 2011, 3:06 AM
I'd probably use a datecolumn, yes. You should probably use it for the Active Date column too.

Dates and times are much the same from this perspective. Formatting is explained here:

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Date

bee
27 Sep 2011, 3:18 AM
Hi,

See my below code and I am still faces the same problem for timefield. I am not sure where is wrong, On screen it gives me NaN/NaN/0NaN for my active time column and when I update using row editing then it shows me value as 01/01/2008. I am very much surprised and tense how to fix this. This was working fine in Extjs 3*.


{ xtype: 'datecolumn',
header : 'Active Date',
align : 'left',
width: 90,
dataIndex : 'active_date',
id : 'active_date',
//format : 'd/m/Y',
renderer : Ext.util.Format.dateRenderer('d/m/Y'),
field : {
xtype: 'datefield',
format : 'd/m/Y'
} },
{ xtype : 'datecolumn',
dataIndex : 'active_time',
header : 'Active Time',
id : 'active_time',
renderer : Ext.util.Format.dateRenderer('H:i'),
field : {
xtype : 'timefield',
format : 'H:i'
},
sortable : true
}

skirtle
27 Sep 2011, 3:34 AM
If you're using a datecolumn then you should be using the format config option, not a renderer.

For a datecolumn to work the data in the field must be a Date object. A Time field will set it to be a Date object, I don't know where your original data is coming from or what manipulation/type conversion you're doing on it. Make sure it's a proper date.

bee
27 Sep 2011, 3:50 AM
I am just using to encode date, This was used for date , so Do i need to use explicitly for time as well.? I am also very confused from where i am getting 01/01/2008 date for timefield, my date column(active date) works fine and perfect. Only issue is with timefield . somewhere I am not able to format it. I changed my render and put only format config, but still I am facing same error.


Ext.JSON.encodeDate = function(d) {
//return d.format('"d/m/Y"');
return Ext.Date.format(d, '"d/m/Y"');};


My worry is I didn't face any problem in EXTjS 3.* with same logic but why am I facing in EXTJS 4.0 ?

skirtle
27 Sep 2011, 4:19 AM
In ExtJS 3 the timefield values were strings. In ExtJS 4 they are dates. You need to decide which you want and standardize within your app.

The 01/01/2008 comes from here:

http://docs.sencha.com/ext-js/4-0/source/Time.html#Ext-form-field-Time-property-initDate

bee
27 Sep 2011, 5:04 AM
Ok. so according my code in previous post, how should I make my timefield in proper format. that is big problem to me. Please could you please post some sample code for it.. I spent my 2 days to know how to format :(

mberrie
27 Sep 2011, 6:25 AM
http://jsbeautifier.org !!!

bee
27 Sep 2011, 7:59 AM
Hi, How to execute the code there ?

mberrie
27 Sep 2011, 8:35 PM
That was meant as encouragement to post nicely formatted code. It's as simple as copying the code there and hitting the big button at the top :D

bee
27 Sep 2011, 11:49 PM
:)) Thats fine, friend. But where is right solution for me ?:-?

bee
29 Sep 2011, 11:46 PM
Hi Skirtle, Thanks for your help. I changed the date object as string type rather date type and then works fine. But in EXT 4.0 Date class is very pain. I didn't find difficult in ext3*

Rashid.softengg
27 Oct 2011, 3:53 AM
{
header : 'Last Sing In',
width : 125,
dataIndex :'last_sign_in_at',
renderer: function(date) { if(date) return date.format("d/m/y, h:m:s T"); }
}

can be use at this way if you want to change it at client side while displaying in the panel.

team.avesta
16 Oct 2012, 5:19 AM
Did anybody find any solution for this problem....
.
if yes then please share it on forum
.
Thanks