Results 1 to 2 of 2

Thread: Use nested data in model

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    73
    Vote Rating
    -1
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •