1. #1
    Sencha User
    Join Date
    Dec 2011
    Location
    White Rock, BC Canada
    Posts
    161
    Answers
    11
    Vote Rating
    0
    WagsMax is on a distinguished road

      0  

    Default Answered: Data being fed into a model does not seem to convert strings to dates

    Answered: Data being fed into a model does not seem to convert strings to dates


    Data being fed into a model does not seem to convert strings to dates for me. In my model, I have defined a field as:
    Code:
                {
                    name: 'completed_date',
                    type: 'date',
                    dateFormat: 'Y-m-d'
                },
    and I am trying to load the model with data:
    Code:
    item = Ext.create('ATMgo.model.Cases', {});
    item.set('completed_date', '2012-10-03');
    The completed_date ends up with string data in it not a date. I want to be able to use the model in a store on a grid which needs the date in a date format, not string format. I thought the model definition would auto-convert the string to a date because the object has type 'date'.

  2. Discovered why the type 'date' was not being recognized in the model... it is because I had the fields defined in a config block. This has happened to me twice now, causing hours of frustration... Touch and Ext have different syntax for defining classes, and I was assuming that my Touch experience would carry over to Ext quite seamlessly Seems I am wrong, and I will now try to watch for this gotcha in the future, but for those of you coming from Touch to Ext, watch out for classes with 'config' blocks you are copying from Touch.

    I am totally confused now as to why we need config blocks in Touch if they are not required in Ext? Can anyone shed light on this, or point me to a blog or what-have-you that explains why the difference between Touch and Ext?

  3. #2
    Sencha User
    Join Date
    Dec 2011
    Location
    White Rock, BC Canada
    Posts
    161
    Answers
    11
    Vote Rating
    0
    WagsMax is on a distinguished road

      0  

    Default


    Discovered why the type 'date' was not being recognized in the model... it is because I had the fields defined in a config block. This has happened to me twice now, causing hours of frustration... Touch and Ext have different syntax for defining classes, and I was assuming that my Touch experience would carry over to Ext quite seamlessly Seems I am wrong, and I will now try to watch for this gotcha in the future, but for those of you coming from Touch to Ext, watch out for classes with 'config' blocks you are copying from Touch.

    I am totally confused now as to why we need config blocks in Touch if they are not required in Ext? Can anyone shed light on this, or point me to a blog or what-have-you that explains why the difference between Touch and Ext?