Hybrid View

  1. #1
    Sencha User
    Join Date
    Aug 2007
    Posts
    21
    Vote Rating
    0
    exebenus is on a distinguished road

      0  

    Default 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:
    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'}
    Any help is welcome!

    Thanks in advance!
    Fernando

  2. #2
    Sencha User Legolas's Avatar
    Join Date
    Apr 2010
    Location
    Brazil/MG
    Posts
    58
    Vote Rating
    3
    Legolas is on a distinguished road

      0  

    Default


    Hi exebenus,

    You should mention the property "allFormats" the formats that must be checked in the typing of values​​, as below:
    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', allFormats: 'j/m/Y'}
    I expect which will help you
    I am sorry my english, I am learning yet
    Portuguese blog: http://wessdevel.blogspot.com.br/
    Twitter: @wlegolas

  3. #3
    Sencha User
    Join Date
    Aug 2007
    Posts
    21
    Vote Rating
    0
    exebenus is on a distinguished road

      0  

    Default


    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!

  4. #4
    Sencha User Legolas's Avatar
    Join Date
    Apr 2010
    Location
    Brazil/MG
    Posts
    58
    Vote Rating
    3
    Legolas is on a distinguished road

      0  

    Default


    Quote Originally Posted by exebenus View Post
    It worked! When I use one digit day ExtJs understands it correctly! The only difference is that the config option is 'altFormats', not 'allFormats'.
    Hi exebenus I wrote wrong, this property is "altFormats" like you wrote.
    Quote Originally Posted by exebenus View Post
    Hi Legolas!
    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.
    You find in class "Ext.Date"
    Quote Originally Posted by exebenus View Post
    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!
    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

  5. #5
    Sencha User
    Join Date
    Aug 2007
    Posts
    21
    Vote Rating
    0
    exebenus is on a distinguished road

      0  

    Default [CLOSED]

    [CLOSED]


    Thanks Legolas!

    It worked perfectly!

    I'll study these codes so I wont bother no one else!

    Thanks !

  6. #6
    Sencha User
    Join Date
    Aug 2007
    Posts
    21
    Vote Rating
    0
    exebenus is on a distinguished road

      0  

    Default


    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).

    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
                            },{
    I must mention that I dont get any errors in javascript console...

Thread Participants: 1

Tags for this Thread