You found a bug! We've classified it as TOUCH-5815 . 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
    May 2015
    Posts
    2
    Vote Rating
    0
    vklinghammer is on a distinguished road

      0  

    Default [2.4] Object with attribute 'length' breaks Ext.data.Reader#extractData

    Heyho,

    just ran into this particular behaviour that I interpreted as a bug in Sencha Touch.

    In data/reader/Reader.js in the extractData function at line 623, you will find this piece of code:

    Code:
    if (!root.length && Ext.isObject(root)) {
        root = [root];
        length = 1;
    }
    
    for (i = 0; i < length; i++) {
        // cut for brevity
        node = root[i];
        // cut for brevity
    }
    Any Object that has a property called "length" will break this piece of code (i.e., the following JSON: { "width": "145.00", "length": "165.00" } when used with a Store). Since it is only valid to iterate through Arrays the way it is done above, I would imagine that checking that would suffice, without nasty side effects. Ext does have a function that can do that.

    Code:
    if (!Ext.isArray(root)) {
        root = [root];
        length = 1;
    }
    
    for (i = 0; i < length; i++) {
        // cut for brevity
        node = root[i];
        // cut for brevity
    }
    Everything is good now. Is there any reason why it was implemented the other way? I fail to see how that made any sense.

  2. #2
    Sencha - Support Team
    Join Date
    Feb 2013
    Location
    California
    Posts
    9,255
    Vote Rating
    251
    Gary Schlosberg has much to be proud of Gary Schlosberg has much to be proud of Gary Schlosberg has much to be proud of Gary Schlosberg has much to be proud of Gary Schlosberg has much to be proud of Gary Schlosberg has much to be proud of Gary Schlosberg has much to be proud of Gary Schlosberg has much to be proud of Gary Schlosberg has much to be proud of

      0  

    Default

    Yes, that's problematic, though I would avoid using 'length' as field name.

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

Similar Threads

  1. Bug in Ext.data.reader.Reader extractData method
    By MichaelOstrovsky in forum Ext:Bugs
    Replies: 2
    Last Post: 3 Apr 2014, 10:43 AM
  2. Replies: 3
    Last Post: 30 Aug 2012, 10:48 AM
  3. Replies: 0
    Last Post: 30 Aug 2012, 6:56 AM
  4. [FIXED] [B3] Wrong result of Ext.data.reader.Reader.extractData()
    By aflx in forum Sencha Touch 2.x: Bugs
    Replies: 7
    Last Post: 11 Mar 2012, 4:06 AM
  5. Replies: 7
    Last Post: 30 Sep 2010, 10:42 AM

Thread Participants: 1