You found a bug! We've classified it as EXTJS-14452 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    28
    Vote Rating
    0
    jonathanmv is on a distinguished road

      0  

    Default stores property of model not set before calling convert function of fields v4.2.1.833

    stores property of model not set before calling convert function of fields v4.2.1.833


    Ext version tested: 4.2.1.883
    Description:

    Find the fiddle

    When setting a convert function on field that uses the record's set method raises an error. The error happens due to the stores property of the model is not set by the time the convert function is called. If a convert function calls the set method, the afterEdit method gets called and tries to notify the stores: an array that has not been defined yet.

    The issue occurs because in the model constructor method, the convert functions start running before the stores property is initialized. A fix could be to move the stores property initialization: line 1041, before the 995 line, where the data processing begins.

    Steps to reproduce the problem:
    • Declare a model with a convert function defined on a field.
    • In the defined convert function call the set method on the record trying to assign a value to another property.
    • Try to instantiate an object for that model using Ext.create and give a data object
      Code:
      var instance = Ext.create('TestModel', {fieldWithConvertFunction: 'A value'});
    The result that was expected:
    • A model instance with the processed value in the properties
    The result that occurs instead:
    • Error: Cannot read property 'length' of undefined

  2. #2
    Sencha - Support Team
    Join Date
    Feb 2013
    Location
    California
    Posts
    3,383
    Vote Rating
    62
    Gary Schlosberg is a jewel in the rough Gary Schlosberg is a jewel in the rough Gary Schlosberg is a jewel in the rough

      0  

    Default


    Thanks for the report. Looks like this issue has already been fixed in version 5. In the hopes of helping you create an override for 4.2.1, I tried to find the bug report that led to the fix, but unfortunately I couldn't.
    Get on the Fast Track with Sencha Training http://sencha.com/training

    Are you a Sencha products veteran who has wondered what it might be like to work at Sencha? If so, please reach out to our recruiting manager: sheryl@sencha.com

  3. #3
    Sencha User
    Join Date
    Apr 2011
    Posts
    28
    Vote Rating
    0
    jonathanmv is on a distinguished road

      0  

    Default An override would be enough

    An override would be enough


    Yes Gary,

    I confirmed both of your statements. In the fiddle you can change the ExtJS version to the 5.x and you'll find another alert saying that the issue was solved for the current version. However the 4.2.2 version still has the issue. It can't be proved through the fiddle tool because that version is not available there, but you can still see the same initialization issue in the source code

    And also, this is the override I used to fix the issue, it could help someone someday.

    Code:
    Ext.define('Overrides.data.Model', {
        override: 'Ext.data.Model',
        /**
         * Creates new Model instance.
         * @param {Object} data An object containing keys corresponding to this model's fields, and their associated values
         */
        constructor: function(data, id, raw, convertedData) {
            /*
             * stores property is not defined prior to convert functions calls on fields
             * http://www.sencha.com/forum/showthread.php?288286-stores-property-of-model-not-set-before-calling-convert-function-of-fields-v4.2.1.833&p=1053477
             */
            this.stores = [];
            this.callParent(arguments);
        }
    This override works for fine for me. Please let me know if there's something wrong on it.

    Thank you very much.

  4. #4
    Sencha - Support Team
    Join Date
    Feb 2013
    Location
    California
    Posts
    3,383
    Vote Rating
    62
    Gary Schlosberg is a jewel in the rough Gary Schlosberg is a jewel in the rough Gary Schlosberg is a jewel in the rough

      0  

    Default


    Thanks for sharing your override with the community. I checked the Fiddle against 4.2.2 and the latest 4.2.3 nightly and you are correct -- apologies for missing that. I'll push this through so it can be fixed in 4.x as well.
    Get on the Fast Track with Sencha Training http://sencha.com/training

    Are you a Sencha products veteran who has wondered what it might be like to work at Sencha? If so, please reach out to our recruiting manager: sheryl@sencha.com

  5. #5
    Sencha - Support Team
    Join Date
    Feb 2013
    Location
    California
    Posts
    3,383
    Vote Rating
    62
    Gary Schlosberg is a jewel in the rough Gary Schlosberg is a jewel in the rough Gary Schlosberg is a jewel in the rough

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi