Results 1 to 3 of 3

Thread: Better auto-loading of associations?

  1. #1
    Sencha User
    Join Date
    Nov 2009
    Posts
    9
    Answers
    1

    Default Better auto-loading of associations?

    Hi,

    I have a model with a hasMany association, with autoLoad set to true.
    When I load an object via the load() static function of the Model class, I get the object back on the callback.
    However, the associated data doesn't load. Only when specifically calling the store (that was created automatically by the hasMany association) does the proxy handle the load request for the associated data.

    Is there a way to have the load() static function on Model to return only after all the data was loaded? That seems like a better behavior for the autoLoad flag on associations.

    In the meantime I subclassed Model and I'm overriding the inheritableStatic function load(), and doing it myself...

    Thanks,
    Have a good weekend

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,451
    Answers
    3997

    Default

    The best way, if you need the associated data up front is to return the associated data in the model load call to return both the model data but also the associated data. Reducing the number of xhr calls can help with overall performance which is more important than developer convenience.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

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

  3. #3
    Sencha User
    Join Date
    Nov 2009
    Posts
    9
    Answers
    1

    Default

    Thanks you the reply.

    My application is loading data from a local database (using Cordova), so the XHR isn't an issue here.

    However, I agree it's better to perform a single request for data. I assume it's good design for the proxy to look into the requesting model to see if it has associations, and query the database for any associations with autoLoad set to true along with the query for the model data.

    I'll be happy to see that in Sencha Touch v3

    Cheers.

Tags for this Thread

Posting Permissions

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