-
19 Nov 2012 6:45 PM #1
DateField invert day & month
DateField invert day & month
Hi everyone!
I'm having a problem trying to use de 'd/m/Y' format in date field.
It works fine except when my input is a one digit day or month. In that case the day and month gets inverted.
Exemples:
02/10/2012 -> Ok!
2/12/2012 -> Gets transformed into 12/02/2012 !
I'm using these properties:
Any help is welcome!Code:text: "Data Disponib.", width: 90, sortable: true, dataIndex: 'provimento[data_inicio_prazo]', filterable: true, filter: {type: 'date', dateFormat: 'd/m/Y'}, renderer: Ext.util.Format.dateRenderer('d/m/Y'), field: {xtype: 'datefield', allowBlank: true, format: 'd/m/Y'}
Thanks in advance!
Fernando
-
20 Nov 2012 3:56 AM #2
Hi exebenus,
You should mention the property "allFormats" the formats that must be checked in the typing of valuesāā, as below:
I expect which will help youCode:text: "Data Disponib.", width: 90, sortable: true, dataIndex: 'provimento[data_inicio_prazo]', filterable: true, filter: {type: 'date', dateFormat: 'd/m/Y'}, renderer: Ext.util.Format.dateRenderer('d/m/Y'), field: {xtype: 'datefield', allowBlank: true, format: 'd/m/Y', allFormats: 'j/m/Y'}I am sorry my english, I am learning yet
Portuguese blog: http://wessdevel.blogspot.com.br/
Twitter: @wlegolas
-
20 Nov 2012 7:51 AM #3
Hi Legolas!
First of all, thanks for your help!!!!
It worked! When I use one digit day ExtJs understands it correctly! The only difference is that the config option is 'altFormats', not 'allFormats'.
Now I have another problem: The input of a one digit month! The validation dont even let me do that!
Example: 01/3/2012 -> It wont let me go foward!
Sorry bothering you again, but can you help with that?
And by the way, where can I find the descriptions of the codes used in the "altFormat" ? I didnt found the 'j' option description in the documentation.
Thanks!
-
20 Nov 2012 11:31 AM #4
Hi exebenus I wrote wrong, this property is "altFormats" like you wrote.
You find in class "Ext.Date"
You need to inform all formats that can be entered by the user, like this:
Code:altFormats: 'j/m/Y|j/n/Y|d/n/Y'
I am sorry my english, I am learning yet
Portuguese blog: http://wessdevel.blogspot.com.br/
Twitter: @wlegolas
-
20 Nov 2012 4:13 PM #5
[CLOSED]
[CLOSED]
Thanks Legolas!
It worked perfectly!
I'll study these codes so I wont bother no one else!
Thanks !
-
20 Nov 2012 5:35 PM #6
One more thing.... When I try this option in a Form it simply doesnt load the field data.
Its very strange, but it only works in grids.
That's my code (I only added the altFormat line).
I must mention that I dont get any errors in javascript console...Code:columnWidth:.33, border:false, layout: 'anchor', defaultType: 'textfield', items: [{ xtype: 'datefield', format: 'd/m/Y', emptyText: 'dd/mm/aaaa', altFormats: 'j/m/Y|j/n/Y|d/n/Y', fieldLabel: 'Distribuição', name: 'processo[data_distribuicao]', dataIndex: 'processo[data_distribuicao]', width: 120 },{
-
21 Nov 2012 1:40 AM #7
exebenus, do you load the data by method "loadRecord"? Because, the field name should be equal the field in your Model.
How are you doing this shipment?I am sorry my english, I am learning yet
Portuguese blog: http://wessdevel.blogspot.com.br/
Twitter: @wlegolas
-
21 Nov 2012 7:32 AM #8
Yes, and the names are equal.
It works without the altFormats line. Its weird!
-
21 Nov 2012 4:06 PM #9
exebenus, try this. In property "altFormats" enter the code below:
If your this code works the problem may be in the date format in your Store.Code:,altFormats: 'j/m/Y|j/n/Y|d/n/Y|m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d|n-j|n/j'
I am sorry my english, I am learning yet
Portuguese blog: http://wessdevel.blogspot.com.br/
Twitter: @wlegolas
-
21 Nov 2012 4:25 PM #10
With this code it worked!!!! Thank you!
Its so strange that even when I used a simple code like "j/m/Y" the data wasnt loaded... Maybe it needed some more complex options to convert the data that came from the store..
Thank you again!


Reply With Quote