1. #1
    Sencha User
    Join Date
    Oct 2010
    Posts
    50
    Answers
    4
    Vote Rating
    0
    marc123 is on a distinguished road

      0  

    Default Unanswered: how to format value of datefield on submit

    Unanswered: how to format value of datefield on submit


    Hi,

    I have a datefield that submits a datetime value to the server. Problem is, the datetime value is not of type date. This is submitted:

    "START_VALIDITY_DATE":"2012-09-07T00:00:00",

    The "T" in 2012-09-07T00:00:00 should not be there. I'd rather only have the date (2012-09-07). How can I tell ext (3.4) to change the format of the datevalue it's submitting?

    Code:
    ,{
                        xtype: 'datecolumn',
                        header: 'Valid from',
                        dataIndex: 'START_VALIDITY_DATE',
                        sortable: true,
                        format: 'd-n-Y',
                        editor:{
                                    xtype: 'datefield',
                                    format:'m/d/Y',
                                    allowBlank: false,
                                    altFormats:'d/n/Y|d n Y',
                                    minValue: (new Date()).format('m/d/Y'),
                                    minText: 'Can\'t set a start date in the past.'
                                    //maxValue: (new Date()).format('m/d/Y')
                                }
    }

  2. #2
    Sencha Premium Member Zdeno's Avatar
    Join Date
    Nov 2009
    Location
    Prague
    Posts
    389
    Answers
    7
    Vote Rating
    17
    Zdeno will become famous soon enough

      0  

    Default


    This is ExtJS 4.x forum.

    Check http://www.sencha.com/forum/showthre...e-submitFormat and override it to Ext 3.

    Why do you need change format? Whats on server side? .Net, PHP or anything else?

  3. #3
    Sencha User
    Join Date
    Oct 2007
    Posts
    221
    Answers
    1
    Vote Rating
    0
    ByteLess is on a distinguished road

      0  

    Default


    how to solve this in EXTJS4.2?
    submitFormat: 'm/d/Y' didn't work for me.

  4. #4
    Sencha Premium Member Zdeno's Avatar
    Join Date
    Nov 2009
    Location
    Prague
    Posts
    389
    Answers
    7
    Vote Rating
    17
    Zdeno will become famous soon enough

      0  

    Default


    Did you check the docs?

    http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Date-cfg-submitFormat

    W
    hat does your script do? Do you get any value from your field? When you take a look into source code you will see following code:
    Code:
    getSubmitValue: function() {
        var format = this.submitFormat || this.format,
            value = this.getValue();
    
    
        return value ? Ext.Date.format(value, format) : '';
    }

  5. #5
    Sencha User
    Join Date
    Oct 2007
    Posts
    221
    Answers
    1
    Vote Rating
    0
    ByteLess is on a distinguished road

      0  

    Default


    Yes I read the docs and thats where I got the 'submitFormat'

    even after using submitFormat the form still posting the value like 2012-09-07T00:00:00

    For now I am using
    myForm.down('#enddate').rawValue

    but wondering why the submitFormat is not working?

    Using 4.2

  6. #6
    Sencha Premium Member Zdeno's Avatar
    Join Date
    Nov 2009
    Location
    Prague
    Posts
    389
    Answers
    7
    Vote Rating
    17
    Zdeno will become famous soon enough

      0  

    Default


    Code:
    submitFormat: 'Y-m-d H:i:s',
    submitValue : true
    works fine for me

  7. #7
    Sencha Premium Member alexander.urban's Avatar
    Join Date
    Nov 2013
    Posts
    92
    Answers
    3
    Vote Rating
    7
    alexander.urban is on a distinguished road

      0  

    Default


    I have the following configuration:

    -> ExtJS 4.2.2
    -> A JSON store with a model.
    -> The model has data fields with dateFormat set to d.m.Y and H:i, respectively.
    -> I load the store via XHR call, getting JSON.
    -> The date and time values sent from the server are "14.04.2014" and "17:00:00"
    -> I bind the form to store.getAt(0)
    -> I have format and submitFormat of the date and time field of the form set to d.m.Y and H:i, respectively.
    -> The form field shows the date value correct, i.e. "14.04.2014" or "17:00:00".
    -> When I use form.updateRecord and then store.sync(), the following is sent in the two fields:
    "2014-04-14T00:00:00" and "2008-01-01T17:00:00"

    What is the problem there?