1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    73
    Vote Rating
    -1
    PhilChill is an unknown quantity at this point

      0  

    Default Answered: Use nested data in model

    Answered: Use nested data in model


    Hey,

    i have there a question. I get over an jsonrpc call some data. Some of that data has data self inside. To make it more clear i include a screenshot

    nestedData.jpg

    I add this two objects to a store and show the body in the view. That is working perfect. Now I want also to add information about the sender in the view and that is the point where i stuck.
    My Model looks so:

    Code:
    Ext.define('MobileLogin.model.Message', {    extend: 'Ext.data.Model',
    
    
        config: {
    	// the fields in the model 
            fields: [
                { name: 'body', type: 'string'}
            ]
        }
    });
    I tried to add the sender as a field there so " { name: 'sender.company', type: 'string' } and also in the view with " itemTpl: '<strong>{body}{sender.company}</strong>' ", that was not working
    So I hope somebody can help with the problem.

  2. You can use sender as a field but with the default type and it will keep it as an object. Or you can use the mapping config of the field to make that field to a nested value.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,404
    Answers
    3549
    Vote Rating
    849
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You can use sender as a field but with the default type and it will keep it as an object. Or you can use the mapping config of the field to make that field to a nested value.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1