1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    46
    Vote Rating
    1
    thantous is on a distinguished road

      0  

    Default Using a Model to load a form

    Hiya,

    Previously in Designer, if I sent a json structure that looked like this via a Model load (REST type)

    Code:
    {key1: {advertiserId: 2, ...}, key2: {someOtherId: 1, ...}}
    I could then setup a model by hand and the fields could be specified as 'key1.advertiserId', or 'key2.someOtherId'. In the form, I would have the same nested names associated to specific fields. When loaded, the nested values would pre-fill the form, which was awesome.

    With Architect, I am unable to create a Model field name in the same way. I do have access to the data I need in the raw property, and can set the Model values using this, but that seems like an odd way to handle the problem. Is there a way using Architect that I can create my model names to read the nested structures?

    So, instead of this (cut from Architect)
    Code:
    Ext.define('CampaignManager.model.CampaignModel', {
        extend: 'Ext.data.Model',
        fields: [
            {
                name: 'advertiserId',
                type: 'int'
            },
            {
                name: 'someOtherId',
                type: 'int'
            }
        ]
    });
    I'd like to do this (to match my
    Code:
    Ext.define('CampaignManager.model.CampaignModel', {
        extend: 'Ext.data.Model',
        fields: [
            {
                name: 'key1.advertiserId',
                type: 'int'
            },
            {
                name: 'key2.someOtherId',
                type: 'int'
            }
        ]
    });
    If that isn't possible, what are my options? Is an override useful here? Create multiple models as use associates?

    Thanks,
    Thanatos

  2. #2
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,487
    Vote Rating
    140
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default

    Sounds like you are looking for the mapping configuration.

    You should set the name to advertiserId and mapping to key1.advertiserId.
    Aaron Conran
    @aconran

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    46
    Vote Rating
    1
    thantous is on a distinguished road

      0  

    Default

    Quote Originally Posted by aconran View Post
    Sounds like you are looking for the mapping configuration.

    You should set the name to advertiserId and mapping to key1.advertiserId.
    Ahhhh yes! That works nicely.

    Thanks a ton!
    Thanatous

Thread Participants: 1