1. #1
    Sencha User olivierpons's Avatar
    Join Date
    Dec 2009
    Location
    Aix en Provence,France
    Posts
    116
    Answers
    6
    Vote Rating
    1
    olivierpons is on a distinguished road

      0  

    Default Answered: ExtJS: store format and Date field format "auto-conversion" problem

    Answered: ExtJS: store format and Date field format "auto-conversion" problem


    Hi,

    I'm defining my model like this:

    Code:
    Ext.define('Gestion.Horaire', {    extend: 'Ext.data.Model',
        fields: [
            {   
                name: 'date_end',
                type: 'date',
                dateFormat: 'Y-m-d H:i:s'
            },
            ...
    When the data is read in JSON format, it's ok: values are 'Y-m-d H:i'.

    Now I want to display them differently in a DateTime component:

    Code:
    Ext.define('Gestion.horaires.form.Panel', {    ...blabla...
        initComponent: function(){
    
    
    
            Ext.apply(this,
                items: [{
                    xtype: 'form',
                    ... blabla ...
                    items: [{
                        fieldLabel: 'Date fin ',
                        name: 'date_end',
    
    
                        xtype: 'datefield',
                        format: 'd/m/Y',
                        allowBlank: false
                    }
                    ... blabla ...
    And when I try in a button event:

    Code:
    var form = this.gsForm.getForm();
    if (form.isValid()) {
        this.store.insert(0, form.getValues());
    }
    The values I read from form.getValues() are in the format 'd/m/Y' and thus when I try to insert, as I can read in the code, in the "createModel" function, it calls 'set()' which calls "Ext.apply.DATE.convert" and, of course, the format 'd/m/Y' isn't recognized, thus Ext.apply.DATE.convert returns null.

    What can I do to convert the date before it's "converted"? Or maybe I'm missing a property I should set to make all of that work?

  2. I found it, it was the property

    Code:
    submitFormat: 'Y-m-d H:i:s',
    Thus the component is declared like this:

    Code:
    {    fieldLabel: 'Date start ',
        name: 'date_debut',
        xtype: 'datefield',
        format: 'd/m/Y',
        submitFormat: 'Y-m-d H:i:s',
        allowBlank: false
    }

  3. #2
    Sencha User olivierpons's Avatar
    Join Date
    Dec 2009
    Location
    Aix en Provence,France
    Posts
    116
    Answers
    6
    Vote Rating
    1
    olivierpons is on a distinguished road

      1  

    Default


    I found it, it was the property

    Code:
    submitFormat: 'Y-m-d H:i:s',
    Thus the component is declared like this:

    Code:
    {    fieldLabel: 'Date start ',
        name: 'date_debut',
        xtype: 'datefield',
        format: 'd/m/Y',
        submitFormat: 'Y-m-d H:i:s',
        allowBlank: false
    }

  4. #3
    Sencha User
    Join Date
    Nov 2013
    Posts
    7
    Vote Rating
    0
    natiishyn is on a distinguished road

      0  

    Default


    Hello guys,From server I receive such data:
    Code:
    expirationDate : "2014-08-27T22:00:00.000+0000"
    and in MVC ExtJS 4 in Model I have this:
    Code:
    fields: [ 
       ... 
       {name: "expirationDate", type: Ext.data.Types.DATE, dateFormat:"yyyy-MM-dd'T'HH:mm:ss.SSSz"}, 
       ...
    But the main problem is that dateFormat. Which should I choose for my date sample?

  5. #4
    Sencha User
    Join Date
    Nov 2010
    Location
    Cork, Ireland
    Posts
    1
    Vote Rating
    0
    mgolka is on a distinguished road

      0  

    Default


    dateFormat: 'c' should do

    Regards

  6. #5
    Sencha User
    Join Date
    Nov 2013
    Posts
    7
    Vote Rating
    0
    natiishyn is on a distinguished road

      0  

    Default


    Yes, it worked. Thank you

Thread Participants: 2

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar