1. #1
    Sencha User
    Join Date
    Oct 2013
    Posts
    4
    Vote Rating
    0
    niklasro is on a distinguished road

      0  

    Default Unanswered: How to extend jsonreader?

    Unanswered: How to extend jsonreader?


    I have an overly nested json that I want to render and I think that the only way, since I can't change the json input, is to extend the json reader and override the reading. My json looks like this:
    Code:
    {
        "productOfferings": [
            {
                "name": "A Product Offering name",
                "description": "A Product Description",
                "productOfferings": [
                    {
                        "id": 5,
                        "name": "A Product Offering name, id 5",
                        "description": "A Product Offering description, id 5",
                        "productSpecification": {
                            "id": 3,
                            "name": "A Product Specification id 3",
                            "description": ""
                        }
                    },
                    {
                        "id": 8,
                        "name": "A Product Offering name, id 8",
                        "description": "A Product Offering description, id 8",
                        "productSpecification": {
                            "id": 9,
                            "name": "A Product Specification id 9",
                            "description": "A Product Description id 9",
                            "productSpecifications": [
                                {
                                    "id": 2,
                                    "name": "A Product Specification id 2",
                                    "description": "A Product Description id 2"
                                },
                                {
                                    "id": 4,
                                    "name": "A Product Specification id 4",
                                    "description": "A Product Description id 4"
                                }
                            ]
                        }
                    }
                ]
            }
        ]
    }
    And I wonder how to extend the jsonreader in Sencha Architect to be able to render this structure. I've seen it done in a fiddle: http://jsfiddle.net/Izhaki/fF5Ux/

    A
    nd I want to try something similar e.g.

    Code:
     Ext.define('MyReader', {        extend : 'Ext.data.reader.Json',        alias : 'reader.myreader',            buildExtractors : function()    {        var me = this;        me.callParent(arguments);        me.getRoot = function ( aObj ) {            // Special case           if aObj[ 'productOfferings' ] == null {              return aObj[ 'productSpecification' ];            }                                        // Default root is `productOfferings`            return aObj[ 'productOfferings' ];        };    }    });
    But how do I achieve this in Sencha Architect? I don't find a way to extend the jsonreader lika above in Sencha Architect. Can you help me?

  2. #2
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    35
    Answers
    4
    Vote Rating
    8
    Scott-1 will become famous soon enough

      0  

    Default


    You extend the reader by over-riding it in the model or the store.

    ,reader: {
    idProperty : 'id',
    root : '',
    read : function(response){
    return response;
    }
    }

  3. #3
    Sencha User
    Join Date
    Oct 2013
    Posts
    4
    Vote Rating
    0
    niklasro is on a distinguished road

      0  

    Default


    Thank you for the answer but I would like more detail. When I try to create an override the IDE complains and I don't think that I did it correctly.

    complain.png

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