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

      0  

    Default 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
    747
    Vote Rating
    70
    Answers
    38
    Zdeno is just really nice Zdeno is just really nice Zdeno is just really nice Zdeno is just really nice

      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
    222
    Vote Rating
    0
    Answers
    1
    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
    747
    Vote Rating
    70
    Answers
    38
    Zdeno is just really nice Zdeno is just really nice Zdeno is just really nice Zdeno is just really nice

      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
    222
    Vote Rating
    0
    Answers
    1
    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
    747
    Vote Rating
    70
    Answers
    38
    Zdeno is just really nice Zdeno is just really nice Zdeno is just really nice Zdeno is just really nice

      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
    178
    Vote Rating
    17
    Answers
    6
    alexander.urban will become famous soon enough

      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?

  8. #8
    Sencha User
    Join Date
    Oct 2009
    Posts
    33
    Vote Rating
    0
    Answers
    2
    w_goldman is on a distinguished road

      0  

    Default

    I am having same issue this element is in the grid panel submits: "Wed Jan 07 2015 00:00:00 GMT-0600 (Central Standard Time)"

    gridcolumn element:


    { menuDisabled:true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), field:{ xtype:'datefield', submitFormat: 'm/d/Y', submitValue : true, autoSync:true, allowBlank:false, editor: new Ext.form.DateField({format: 'm/d/Y', submitFormat: 'm/d/Y', submitValue : true}) }, header: 'Start Date', dataIndex: 'startDate', flex: 11 / 100, sortable: true, hideable: false }

  9. #9
    Sencha Premium Member alexander.urban's Avatar
    Join Date
    Nov 2013
    Posts
    178
    Vote Rating
    17
    Answers
    6
    alexander.urban will become famous soon enough

      0  

    Default

    You have to look into your model. Your model should have a complete field definition, something like:

    fields:[{
    name:'startDate'
    type:'date',
    submitFormat:'m/d/Y'

    }]

    My problem was that I didn't specify the type, and if it isn't set to type:'date', format and submitFormat are ignored.

  10. #10
    Sencha User
    Join Date
    Oct 2009
    Posts
    33
    Vote Rating
    0
    Answers
    2
    w_goldman is on a distinguished road

      0  

    Default

    My model has exactly what you specified, still does not submit format of m/d/Y.(I did not post my model def in the previous reply)