Answered: Synchronous association call or something

Answered: Synchronous association call or something

Hello all,

Is it possible to make use of associations without making a new call to server? When I try to record.getBelongsToModelName(), i need to run a callback to get the data returned and use it. However, I think the models should be able to prepare the data for the store with the associated data.

It depends on how much data you load from the server, if you load your parent model... if you have nested data, the associations are filled and you can access these by using yourParentModel.assocName() (giving you a store to the association). If you haven't nested data and want the associations to be lazy loaded, the association stores are there, but not yet filled - so yourParentModel.assocName().load() would load those data and if you need to do something with this loaded data you have to make a callback on success... synchronous wouldn't work there...

if the store to the association is correctly built, you can also access it with .assocNameStore on your model, which is somehow easier in doing console-debugging stuff...

It depends on how much data you load from the server, if you load your parent model... if you have nested data, the associations are filled and you can access these by using yourParentModel.assocName() (giving you a store to the association). If you haven't nested data and want the associations to be lazy loaded, the association stores are there, but not yet filled - so yourParentModel.assocName().load() would load those data and if you need to do something with this loaded data you have to make a callback on success... synchronous wouldn't work there...

if the store to the association is correctly built, you can also access it with .assocNameStore on your model, which is somehow easier in doing console-debugging stuff...