1. #11
    Sencha Premium Member
    Join Date
    Feb 2011
    Posts
    12
    Vote Rating
    0
    Qanik is on a distinguished road

      0  

    Default


    This is REALLY counter-intuitive. Are there any plans to improve Ext.create(..) to load nested data?

  2. #12
    Sencha User
    Join Date
    Apr 2009
    Posts
    11
    Vote Rating
    1
    matthewdfleming is on a distinguished road

      0  

    Default Here's how we did create...

    Here's how we did create...


    We had this same problem in sencha touch.. the solution was like this..

    This code is in a button click handler for a 'create new assessment' button. The idea is that a create call is supposed to be made to the server and the result of that call should be an 'Assessment.' The json stream coming back has entries for all of the related items (e.g. categories, assessor, etc).

    Code:
            var me = this;
    
    
            // create a new assessment with the client and tool
            var newOne = Ext.create('helium.model.Assessment');
    
    
            // save it so that the 'create' call will happen on the server
            newOne.save({
                success: function (record) {
                    // for some reason the 'create' flow doesn't resolve associations
                    // need to manually push through a reader
                    var reader = Ext.create('Ext.data.reader.Json', {
                        model: 'helium.model.Assessment'
                    });
                    var resultSet = reader.read(record.data); //the record itself won't work, just the .data portion
                    var assessment = resultSet.getRecords()[0];
                    // 'assessment' is now fully read in with associations
                },
                scope: me
            });
    Here's the model object (using a REST proxy).. the writer is a custom writer that will also push all of the related items down on a save/update call..
    Code:
    Ext.define('helium.model.Assessment', {
    
    
        extend: 'Ext.data.Model',
        config: {
            useCache: false,
            fields: [
                'id', 'version', 'startDate', 'type',
                {name: 'allowedActions', persist: false},
                {name: 'status', persist: false},
                {name: 'baseType', persist: false},
                {name: 'major', persist: false},
                {name: 'minor', persist: false}
    
    
            ],
            hasMany: [
                {model: 'helium.model.Category', name: 'categories'}
            ],
            hasOne: [
                {model: 'helium.model.Assessor'},
                {model: 'helium.model.OrgUnit'},
                {model: 'helium.model.Client'}
            ],
            proxy: {
                type: 'rest',
                writer: Ext.create('helium.util.IncludeRelationshipJsonWriter'),
                api: {
                    create: '../data/assessment/create',
                    read: '../data/assessment/read',
                    update: '../data/assessment/update',
                    destroy: '../data/assessment/delete'
                },
                reader: {
                    type: 'json',
                    rootProperty: 'assessment'
                }
            }
        }
    });

  3. #13
    Sencha User
    Join Date
    Jul 2010
    Posts
    50
    Answers
    1
    Vote Rating
    -1
    hdave is an unknown quantity at this point

      0  

    Default


    Yet another person that found this thread. I am using 4.2.2 and am frankly stunned that this doesn't work. I really hate the idea of creating a reader just to do this....

  4. #14
    Sencha User
    Join Date
    Apr 2014
    Posts
    2
    Vote Rating
    0
    adrian_crouch is on a distinguished road

      0  

    Default


    It neither seems to work with extjs 5 ..

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