Results 1 to 5 of 5

Thread: Nested Models?

  1. #1
    Sencha Premium Member
    Join Date
    Sep 2008
    Posts
    710

    Default Nested Models?

    Can you create nested models where a property is an array of another model object? Take for instance the Cart, Product scenario. If I have the following objects defined:

    Code:
    Ext.regModel("Cart", {
        fields: [
            {name: 'custName',  mapping: 'custName',  type: 'string'},
            {name: 'ordernumber',  mapping: 'ordernumber',  type: 'int'}
        ]
          
    });
    
    Ext.regModel("Product", {
        fields: [
            {name: 'productName',  mapping: 'productName',  type: 'string'},
            {name: 'price',  mapping: 'price',  type: 'float'},
            {name: 'qty',  mapping: 'qty',  type: 'int'}
        ]
          
    });
    Can I define a field in cart that contains many Products? If so, what exactly does the field type look like and how would I add the products to the Cart object? I know I can define the association like this in the cart object:

    Code:
        associations: [
            {type: 'hasMany', model: 'Product',    name: 'products'},
        ]
    But does that become a "products" property of the Cart object into which I can add instances of product?

    Don't see any model examples of exactly how to do this. Thanks!

  2. #2
    Sencha Premium Member
    Join Date
    Sep 2008
    Posts
    710

    Default

    Nevermind, this link here explains it well enough

  3. #3
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    Quote Originally Posted by Bucs View Post
    Nevermind, this link here explains it well enough
    haha, nice link
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  4. #4

  5. #5
    Sencha User
    Join Date
    Mar 2014
    Posts
    2

    Default links are not working

    Both the links mentioned above are not working as they are for old ext versions. Can you please add the relevant link for 4.2 version.

Similar Threads

  1. Nested List and nested models ?
    By shrell in forum Sencha Touch 1.x: Discussion
    Replies: 6
    Last Post: 14 Dec 2011, 7:11 AM
  2. models inside models
    By kortovos in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 27 Sep 2010, 3:43 AM
  3. XTemplate an nested models
    By screw in forum Ext GWT: Help & Discussion (1.x)
    Replies: 4
    Last Post: 13 Aug 2009, 3:53 AM
  4. Rendering nested models on a grid
    By mathaj77 in forum Ext GWT: Discussion
    Replies: 1
    Last Post: 6 Aug 2009, 4:30 AM
  5. XTemplate an nested models
    By screw in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 1 Feb 2009, 10:18 AM

Posting Permissions

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