Results 1 to 3 of 3

Thread: How to get parent model ?

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Location
    Vancouver, Canada
    Posts
    157
    Answers
    5

    Default How to get parent model ?

    1. is it possible to get the parent model (in a hasMany relationship) if the parent model does not have an ID yet (has not been saved to server)?

    2. is it possible to get the parent model without declaring a belongsTo relationship? The relationship is there, the child is in a store that belongs to the parent. Can I get a reference to the parent without the belongsTo relationship?

    Thanks!

  2. #2
    Sencha User
    Join Date
    Dec 2011
    Posts
    224
    Answers
    13

    Default

    why not defining the belongsTo association ?
    life could be much easier for you ;D
    the "inverse" pointer from the associated record to the host record is only set if you declare the association.
    also only if you load the asociated record
    also the inverse pointer has some bugs.
    best option is for question #1 you already have the pointer to the parent model (as is not saved, exists in the client side), find a way to work with it not using the associated model.

    for second question, i guess the parent model is saved, or the both questions could be the same, and since theres no belongsTo you can load it manually. using the foreign key. also if you already have the parent model loaded, well just use that pointer because the child record wont have any pointer to the parent.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Location
    Vancouver, Canada
    Posts
    157
    Answers
    5

    Default

    bump

Posting Permissions

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